Add transitional API for maps (aka tries).

This commit is contained in:
David Anderson
2014-06-22 22:32:08 -07:00
parent d7b66c2515
commit 4ee04b8a7b
2 changed files with 65 additions and 48 deletions
+17 -1
View File
@@ -49,7 +49,7 @@
*
* @return New Map Handle, which must be freed via CloseHandle().
*/
native Handle:CreateTrie();
native AdtMap:CreateTrie();
/**
* Sets a value in a hash map, either inserting a new entry or replacing an old one.
@@ -155,6 +155,22 @@ native ClearTrie(Handle:map);
*/
native GetTrieSize(Handle:map);
/* Object-oriented wrapper for maps. */
methodmap AdtMap < Handle {
public AdtMap() = CreateTrie;
public SetValue() = SetTrieValue;
public SetArray() = SetTrieArray;
public SetString() = SetTrieString;
public GetValue() = GetTrieValue;
public GetArray() = GetTrieArray;
public GetString() = GetTrieString;
public Remove() = RemoveFromTrie;
public Clear() = ClearTrie;
property int Size {
public get() = GetTrieSize;
};
};
/**
* Creates a snapshot of all keys in the map. If the map is changed after this
* call, the changes are not reflected in the snapshot. Keys are not sorted.