|
@@ -91,7 +91,12 @@
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Update a specific value associated to a key
|
|
|
|
+ * @param key defines the key to use
|
|
|
|
+ * @param value defines the value to store
|
|
|
|
+ * @returns true if the value was updated (or false if the key was not found)
|
|
|
|
+ */
|
|
public set(key: string, value: T): boolean {
|
|
public set(key: string, value: T): boolean {
|
|
if (this._data[key] === undefined) {
|
|
if (this._data[key] === undefined) {
|
|
return false;
|
|
return false;
|
|
@@ -102,7 +107,8 @@
|
|
|
|
|
|
/**
|
|
/**
|
|
* Get the element of the given key and remove it from the dictionary
|
|
* Get the element of the given key and remove it from the dictionary
|
|
- * @param key
|
|
|
|
|
|
+ * @param key defines the key to search
|
|
|
|
+ * @returns the value associated with the key or null if not found
|
|
*/
|
|
*/
|
|
public getAndRemove(key: string): Nullable<T> {
|
|
public getAndRemove(key: string): Nullable<T> {
|
|
let val = this.get(key);
|
|
let val = this.get(key);
|
|
@@ -136,6 +142,9 @@
|
|
this._count = 0;
|
|
this._count = 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Gets the current count
|
|
|
|
+ */
|
|
public get count() {
|
|
public get count() {
|
|
return this._count;
|
|
return this._count;
|
|
}
|
|
}
|
|
@@ -157,6 +166,7 @@
|
|
* If the callback returns null or undefined the method will iterate to the next key/value pair
|
|
* If the callback returns null or undefined the method will iterate to the next key/value pair
|
|
* Note that you can remove any element in this dictionary in the callback implementation
|
|
* Note that you can remove any element in this dictionary in the callback implementation
|
|
* @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
|
|
* @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
|
|
|
|
+ * @returns the first item
|
|
*/
|
|
*/
|
|
public first<TRes>(callback: (key: string, val: T) => TRes) {
|
|
public first<TRes>(callback: (key: string, val: T) => TRes) {
|
|
for (let cur in this._data) {
|
|
for (let cur in this._data) {
|