Skip to content

Instantly share code, notes, and snippets.

@geoffreymcgill
Created April 26, 2017 05:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geoffreymcgill/eb76027eada2f672f0814f2c2c8cb71b to your computer and use it in GitHub Desktop.
Save geoffreymcgill/eb76027eada2f672f0814f2c2c8cb71b to your computer and use it in GitHub Desktop.
/// <reference path="./bridge.d.ts" />
declare module Bridge.Collections {
/** @namespace System.Collections.Generic */
/**
* Internal helper functions for working with enumerables.
*
* @static
* @abstract
* @class Bridge.Collections.EnumerableHelpers
*/
export interface Bridge.Collections.EnumerableHelpers {
}
export interface Bridge.Collections.EnumerableHelpersFunc extends Function {
prototype: Bridge.Collections.EnumerableHelpers;
new (): Bridge.Collections.EnumerableHelpers;
/**
* Converts an enumerable to an array using the same logic as does List{T}.
*
* @static
* @this Bridge.Collections.EnumerableHelpers
* @memberof Bridge.Collections.EnumerableHelpers
* @param {Function} T
* @param {System.Collections.Generic.IEnumerable$1} source The enumerable to convert.
* @return {Array.<T>} The resulting array.
*/
toArray<T>(T: {prototype: T}, source: System.Collections.Generic.IEnumerable$1<T>): T[];
/**
* Converts an enumerable to an array using the same logic as does List{T}.
*
* @static
* @this Bridge.Collections.EnumerableHelpers
* @memberof Bridge.Collections.EnumerableHelpers
* @param {Function} T
* @param {System.Collections.Generic.IEnumerable$1} source The enumerable to convert.
* @param {System.Int32} length The number of items stored in the resulting array, 0-indexed.
* @return {Array.<T>} The resulting array. The length of the array may be greater than <b />,
which is the actual number of elements in the array.
*/
toArray$1<T>(T: {prototype: T}, source: System.Collections.Generic.IEnumerable$1<T>, length: {v: number}): T[];
}
var Bridge.Collections.EnumerableHelpers: Bridge.Collections.EnumerableHelpersFunc;
}
declare module System.Collections {
export interface BitArray extends System.Collections.ICollection,System.ICloneable {
getItem(index: number): boolean;
setItem(index: number, value: boolean): void;
Length: number;
/**
* Gets the number of elements contained in the ICollection.
*
* @instance
* @public
* @readonly
* @memberof System.Collections.BitArray
* @function Count
* @type number
*/
Count: number;
IsReadOnly: boolean;
IsSynchronized: boolean;
/**
* Copies the entire List to a compatible one-dimensional array, starting at the specified index of the target array.
*
* @instance
* @public
* @this System.Collections.BitArray
* @memberof System.Collections.BitArray
* @param {Array} array The one-dimensional Array that is the destination of the elements copied from List.
* @param {number} index
* @return {void}
*/
copyTo(array: Array, index: number): void;
get(index: number): boolean;
set(index: number, value: boolean): void;
setAll(value: boolean): void;
and(value: System.Collections.BitArray): System.Collections.BitArray;
or(value: System.Collections.BitArray): System.Collections.BitArray;
xor(value: System.Collections.BitArray): System.Collections.BitArray;
not(): System.Collections.BitArray;
clone(): System.Object;
getEnumerator(): System.Collections.IEnumerator;
}
export interface BitArrayFunc extends Function {
prototype: BitArray;
BitArrayEnumeratorSimple: System.Collections.BitArray.BitArrayEnumeratorSimpleFunc;
$ctor3: {
new (length: number): BitArray
};
$ctor4: {
new (length: number, defaultValue: boolean): BitArray
};
$ctor1: {
new (bytes: number[]): BitArray
};
ctor: {
new (values: boolean[]): BitArray
};
$ctor5: {
new (values: number[]): BitArray
};
$ctor2: {
new (bits: System.Collections.BitArray): BitArray
};
/**
* Used for conversion between different representations of bit array.
Returns (n+(div-1))/div, rearranged to avoid arithmetic overflow.
For example, in the bit to int case, the straightforward calc would
be (n+31)/32, but that would cause overflow. So instead it's
rearranged to ((n-1)/32) + 1, with special casing for 0.
Usage:
GetArrayLength(77, BitsPerInt32): returns how many ints must be
allocated to store 77 bits.
*
* @static
* @private
* @this System.Collections.BitArray
* @memberof System.Collections.BitArray
* @param {number} n
* @param {number} div use a conversion constant, e.g. BytesPerInt32 to get
how many ints are required to store n bytes
* @return {number}
*/
getArrayLength(n: number, div: number): number;
}
var BitArray: BitArrayFunc;
module BitArray {
export interface BitArrayEnumeratorSimple extends System.Collections.IEnumerator {
Current: System.Object;
moveNext(): boolean;
reset(): void;
}
export interface BitArrayEnumeratorSimpleFunc extends Function {
prototype: BitArrayEnumeratorSimple;
}
}
export interface HashHelpers {
}
export interface HashHelpersFunc extends Function {
prototype: HashHelpers;
new (): HashHelpers;
primes: number[];
MaxPrimeArrayLength: number;
isPrime(candidate: number): boolean;
getPrime(min: number): number;
getMinPrime(): number;
expandPrime(oldSize: number): number;
}
var HashHelpers: HashHelpersFunc;
}
declare module System.Collections.Generic {
export interface BitHelper {
markBit(bitPosition: number): void;
isMarked(bitPosition: number): boolean;
}
export interface BitHelperFunc extends Function {
prototype: BitHelper;
toIntArrayLength(n: number): number;
}
var BitHelper: BitHelperFunc;
export interface HashSet$1<T> extends System.Collections.Generic.ICollection$1<T>,System.Collections.Generic.ISet$1<T> {
Count: number;
IsReadOnly: boolean;
Comparer: System.Collections.Generic.IEqualityComparer$1<T>;
"System$Collections$Generic$ICollection$1$" + Bridge.getTypeAlias(T) + "$add"(item: T): void;
add(item: T): boolean;
clear(): void;
arrayClear(array: Array, index: number, length: number): void;
contains(item: T): boolean;
copyTo(array: T[], arrayIndex: number): void;
copyTo$1(array: T[]): void;
copyTo$2(array: T[], arrayIndex: number, count: number): void;
remove(item: T): boolean;
getEnumerator(): System.Collections.Generic.HashSet$1.Enumerator<T>;
"System$Collections$Generic$IEnumerable$1$" + Bridge.getTypeAlias(T) + "$getEnumerator"(): System.Collections.Generic.IEnumerator$1<T>;
System$Collections$IEnumerable$getEnumerator(): System.Collections.IEnumerator;
unionWith(other: System.Collections.Generic.IEnumerable$1<T>): void;
intersectWith(other: System.Collections.Generic.IEnumerable$1<T>): void;
exceptWith(other: System.Collections.Generic.IEnumerable$1<T>): void;
symmetricExceptWith(other: System.Collections.Generic.IEnumerable$1<T>): void;
isSubsetOf(other: System.Collections.Generic.IEnumerable$1<T>): boolean;
isProperSubsetOf(other: System.Collections.Generic.IEnumerable$1<T>): boolean;
isSupersetOf(other: System.Collections.Generic.IEnumerable$1<T>): boolean;
isProperSupersetOf(other: System.Collections.Generic.IEnumerable$1<T>): boolean;
overlaps(other: System.Collections.Generic.IEnumerable$1<T>): boolean;
setEquals(other: System.Collections.Generic.IEnumerable$1<T>): boolean;
removeWhere(match: {(arg: T): boolean}): number;
trimExcess(): void;
initialize(capacity: number): void;
increaseCapacity(): void;
setCapacity(newSize: number, forceNewHashCodes: boolean): void;
addIfNotPresent(value: T): boolean;
containsAllElements(other: System.Collections.Generic.IEnumerable$1<T>): boolean;
isSubsetOfHashSetWithSameEC(other: System.Collections.Generic.HashSet$1<T>): boolean;
intersectWithHashSetWithSameEC(other: System.Collections.Generic.HashSet$1<T>): void;
intersectWithEnumerable(other: System.Collections.Generic.IEnumerable$1<T>): void;
internalIndexOf(item: T): number;
symmetricExceptWithUniqueHashSet(other: System.Collections.Generic.HashSet$1<T>): void;
symmetricExceptWithEnumerable(other: System.Collections.Generic.IEnumerable$1<T>): void;
addOrGetLocation(value: T, location: {v: number}): boolean;
checkUniqueAndUnfoundElements(other: System.Collections.Generic.IEnumerable$1<T>, returnIfUnfound: boolean): System.Collections.Generic.HashSet$1.ElementCount<T>;
toArray(): T[];
internalGetHashCode(item: T): number;
}
export interface HashSet$1Func extends Function {
<T>($T: Bridge.TypeRef<T>): {
prototype: HashSet$1<T>;
ElementCount: System.Collections.Generic.HashSet$1.ElementCountFunc;
Enumerator: System.Collections.Generic.HashSet$1.EnumeratorFunc;
Slot: System.Collections.Generic.HashSet$1.SlotFunc;
new (): HashSet$1<T>;
ctor: {
new (): HashSet$1<T>
};
$ctor3: {
new (comparer: System.Collections.Generic.IEqualityComparer$1<T>): HashSet$1<T>
};
$ctor1: {
new (collection: System.Collections.Generic.IEnumerable$1<T>): HashSet$1<T>
};
$ctor2: {
new (collection: System.Collections.Generic.IEnumerable$1<T>, comparer: System.Collections.Generic.IEqualityComparer$1<T>): HashSet$1<T>
};
hashSetEquals(set1: System.Collections.Generic.HashSet$1<T>, set2: System.Collections.Generic.HashSet$1<T>, comparer: System.Collections.Generic.IEqualityComparer$1<T>): boolean;
areEqualityComparersEqual(set1: System.Collections.Generic.HashSet$1<T>, set2: System.Collections.Generic.HashSet$1<T>): boolean;
}
}
var HashSet$1: HashSet$1Func;
module HashSet$1 {
export interface ElementCount<T> {
getHashCode(): System.Collections.Generic.HashSet$1.ElementCount(T);
equals(o: System.Collections.Generic.HashSet$1.ElementCount(T)): Boolean;
$clone(to: System.Collections.Generic.HashSet$1.ElementCount(T)): System.Collections.Generic.HashSet$1.ElementCount(T);
}
export interface ElementCountFunc extends Function {
<T>($T: Bridge.TypeRef<T>): {
prototype: ElementCount<T>;
new (): ElementCount<T>;
}
}
export interface Enumerator<T> extends System.Collections.Generic.IEnumerator$1<T> {
Current: T;
System$Collections$IEnumerator$current: System.Object;
dispose(): void;
moveNext(): boolean;
System$Collections$IEnumerator$reset(): void;
getHashCode(): System.Collections.Generic.HashSet$1.Enumerator(T);
equals(o: System.Collections.Generic.HashSet$1.Enumerator(T)): Boolean;
$clone(to: System.Collections.Generic.HashSet$1.Enumerator(T)): System.Collections.Generic.HashSet$1.Enumerator(T);
}
export interface EnumeratorFunc extends Function {
<T>($T: Bridge.TypeRef<T>): {
prototype: Enumerator<T>;
new (): Enumerator<T>;
ctor: {
new (): Enumerator<T>
};
}
}
export interface Slot<T> {
getHashCode(): System.Collections.Generic.HashSet$1.Slot(T);
equals(o: System.Collections.Generic.HashSet$1.Slot(T)): Boolean;
$clone(to: System.Collections.Generic.HashSet$1.Slot(T)): System.Collections.Generic.HashSet$1.Slot(T);
}
export interface SlotFunc extends Function {
<T>($T: Bridge.TypeRef<T>): {
prototype: Slot<T>;
new (): Slot<T>;
}
}
}
export interface Queue$1<T> extends System.Collections.Generic.IEnumerable$1<T>,System.Collections.ICollection {
Count: number;
IsReadOnly: boolean;
copyTo(array: Array, index: number): void;
copyTo$1(array: T[], arrayIndex: number): void;
clear(): void;
enqueue(item: T): void;
getEnumerator(): System.Collections.Generic.Queue$1.Enumerator<T>;
"System$Collections$Generic$IEnumerable$1$" + Bridge.getTypeAlias(T) + "$getEnumerator"(): System.Collections.Generic.IEnumerator$1<T>;
System$Collections$IEnumerable$getEnumerator(): System.Collections.IEnumerator;
dequeue(): T;
peek(): T;
contains(item: T): boolean;
getElement(i: number): T;
toArray(): T[];
setCapacity(capacity: number): void;
moveNext(index: number): number;
trimExcess(): void;
}
export interface Queue$1Func extends Function {
<T>($T: Bridge.TypeRef<T>): {
prototype: Queue$1<T>;
Enumerator: System.Collections.Generic.Queue$1.EnumeratorFunc;
new (): Queue$1<T>;
ctor: {
new (): Queue$1<T>
};
$ctor2: {
new (capacity: number): Queue$1<T>
};
$ctor1: {
new (collection: System.Collections.Generic.IEnumerable$1<T>): Queue$1<T>
};
}
}
var Queue$1: Queue$1Func;
module Queue$1 {
export interface Enumerator<T> extends System.Collections.Generic.IEnumerator$1<T>,System.Collections.IEnumerator {
Current: T;
System$Collections$IEnumerator$current: System.Object;
dispose(): void;
moveNext(): boolean;
System$Collections$IEnumerator$reset(): void;
getHashCode(): System.Collections.Generic.Queue$1.Enumerator(T);
equals(o: System.Collections.Generic.Queue$1.Enumerator(T)): Boolean;
$clone(to: System.Collections.Generic.Queue$1.Enumerator(T)): System.Collections.Generic.Queue$1.Enumerator(T);
}
export interface EnumeratorFunc extends Function {
<T>($T: Bridge.TypeRef<T>): {
prototype: Enumerator<T>;
new (): Enumerator<T>;
ctor: {
new (): Enumerator<T>
};
}
}
}
export interface Stack$1<T> extends System.Collections.Generic.IEnumerable$1<T>,System.Collections.ICollection {
Count: number;
IsReadOnly: boolean;
clear(): void;
contains(item: T): boolean;
copyTo$1(array: T[], arrayIndex: number): void;
copyTo(array: Array, arrayIndex: number): void;
getEnumerator(): System.Collections.Generic.Stack$1.Enumerator<T>;
"System$Collections$Generic$IEnumerable$1$" + Bridge.getTypeAlias(T) + "$getEnumerator"(): System.Collections.Generic.IEnumerator$1<T>;
System$Collections$IEnumerable$getEnumerator(): System.Collections.IEnumerator;
trimExcess(): void;
peek(): T;
pop(): T;
push(item: T): void;
toArray(): T[];
}
export interface Stack$1Func extends Function {
<T>($T: Bridge.TypeRef<T>): {
prototype: Stack$1<T>;
Enumerator: System.Collections.Generic.Stack$1.EnumeratorFunc;
new (): Stack$1<T>;
ctor: {
new (): Stack$1<T>
};
$ctor2: {
new (capacity: number): Stack$1<T>
};
$ctor1: {
new (collection: System.Collections.Generic.IEnumerable$1<T>): Stack$1<T>
};
}
}
var Stack$1: Stack$1Func;
module Stack$1 {
export interface Enumerator<T> extends System.Collections.Generic.IEnumerator$1<T>,System.Collections.IEnumerator {
Current: T;
System$Collections$IEnumerator$current: System.Object;
dispose(): void;
moveNext(): boolean;
System$Collections$IEnumerator$reset(): void;
getHashCode(): System.Collections.Generic.Stack$1.Enumerator(T);
equals(o: System.Collections.Generic.Stack$1.Enumerator(T)): Boolean;
$clone(to: System.Collections.Generic.Stack$1.Enumerator(T)): System.Collections.Generic.Stack$1.Enumerator(T);
}
export interface EnumeratorFunc extends Function {
<T>($T: Bridge.TypeRef<T>): {
prototype: Enumerator<T>;
new (): Enumerator<T>;
ctor: {
new (): Enumerator<T>
};
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment