forked from NativeScript/NativeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontainers.d.ts
More file actions
101 lines (90 loc) · 2.96 KB
/
containers.d.ts
File metadata and controls
101 lines (90 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
declare module "utils/containers" {
/**
* An interface used to compare two instances of a same class.
*/
interface IEqualityComparer<T> {
/**
* Compares two instances of a same class.
* @param x - First object to compare.
* @param y - Second object to compare.
* Returns true if objects are equal, otherwise false.
*/
equals(x: T, y: T): boolean;
/**
* Generates an unique hash code for an object instance.
*/
getHashCode(obj: T): number;
}
/**
* Helper class used to sort arrays.
*/
class ArraySortHelper {
/**
* Sorts an array using a comparer function to order elements.
* @param keys - The array which will be sorted.
* @param index - Starting index for sorting
* @param length - How many items to sort.
* @param compareFn - A function that compares two array members.
*/
public static sort<T>(keys: Array<T>, index: number, length: number, compareFn: (a: T, b: T) => number);
}
/**
* Represents a collection of keys and values.
*/
class Dictionary<TKey, TValue> {
/**
* The size of the dictionary.
*/
count: number;
/**
* Creates an instance of a Dictionary.
*/
constructor(comparer: IEqualityComparer<TKey>);
/**
* Iterates through all items and executes a callback function.
* @param callbackfn - A function that will be executed for each item.
*/
public forEach(callbackfn: (key: TKey, value: TValue) => void);
/**
* Clears the entire Dictionary.
*/
public clear(): void;
/**
* Removes the item associated with a given key.
* @param key - A key to remove.
*/
public remove(key: TKey): boolean;
/**
* Returns the item associated with a given key.
* @param key - A lookup key.
*/
public get(key: TKey): TValue;
/**
* Returns if an item associated with a given key exist in the Dictionary.
* @param key - A lookup key.
*/
public has(key: TKey): boolean;
/**
* Associates a value with a key.
* @param key - A key for the value.
* @param value - The real value.
*/
public set(key: TKey, value: TValue): void;
}
/**
* An implementation of IEqualityComparer that works with strings.
*/
class StringComparer implements IEqualityComparer<string> {
/**
* Compares two strings.
* @param x - First string to compare.
* @param y - Second string to compare.
* Returns true if strings are equal, otherwise false.
*/
equals(x: string, y: string): boolean;
/**
* Generates an unique hash code for a string.
*/
getHashCode(str: string): number;
}
}