Remove map snapshot API (was not yet ready).
This commit is contained in:
@@ -154,47 +154,3 @@ native ClearTrie(Handle:map);
|
||||
* @error Invalid Handle.
|
||||
*/
|
||||
native GetTrieSize(Handle:map);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param map Map Handle.
|
||||
* @return New Map Snapshot Handle, which must be closed via CloseHandle().
|
||||
* @error Invalid Handle.
|
||||
*/
|
||||
native Handle:CreateTrieSnapshot(Handle:map);
|
||||
|
||||
/**
|
||||
* Returns the number of keys in a map snapshot. Note that this may be
|
||||
* different from the size of the map, since the map can change after the
|
||||
* snapshot of its keys was taken.
|
||||
*
|
||||
* @param snapshot Map snapshot.
|
||||
* @return Number of keys.
|
||||
* @error Invalid Handle.
|
||||
*/
|
||||
native TrieSnapshotLength(Handle:snapshot);
|
||||
|
||||
/**
|
||||
* Returns the buffer size required to store a given key. That is, it returns
|
||||
* the length of the key plus one.
|
||||
*
|
||||
* @param snapshot Map snapshot.
|
||||
* @param index Key index (starting from 0).
|
||||
* @return Buffer size required to store the key string.
|
||||
* @error Invalid Handle or index out of range.
|
||||
*/
|
||||
native TrieSnapshotKeyBufferSize(Handle:snapshot, index);
|
||||
|
||||
/**
|
||||
* Retrieves the key string of a given key in a map snapshot.
|
||||
*
|
||||
* @param snapshot Map snapshot.
|
||||
* @param index Key index (starting from 0).
|
||||
* @param buffer String buffer.
|
||||
* @param maxlength Maximum buffer length.
|
||||
* @return Number of bytes written to the buffer.
|
||||
* @error Invalid Handle or index out of range.
|
||||
*/
|
||||
native GetTrieSnapshotKey(Handle:snapshot, index, String:buffer[], maxlength);
|
||||
|
||||
@@ -125,36 +125,6 @@ public Action:RunTests(argc)
|
||||
if (GetTrieSize(trie))
|
||||
ThrowError("size should be 0");
|
||||
|
||||
SetTrieString(trie, "adventure", "time!");
|
||||
SetTrieString(trie, "butterflies", "bees");
|
||||
SetTrieString(trie, "egg", "egg");
|
||||
|
||||
new Handle:keys = CreateTrieSnapshot(trie);
|
||||
{
|
||||
if (TrieSnapshotLength(keys) != 3)
|
||||
ThrowError("trie snapshot length should be 3");
|
||||
|
||||
new bool:found[3];
|
||||
for (new i = 0; i < TrieSnapshotLength(keys); i++) {
|
||||
new size = TrieSnapshotKeyBufferSize(keys, i);
|
||||
new String:buffer[size];
|
||||
GetTrieSnapshotKey(keys, i, buffer, size);
|
||||
|
||||
if (strcmp(buffer, "adventure") == 0)
|
||||
found[0] = true;
|
||||
else if (strcmp(buffer, "butterflies") == 0)
|
||||
found[1] = true;
|
||||
else if (strcmp(buffer, "egg") == 0)
|
||||
found[2] = true;
|
||||
else
|
||||
ThrowError("unexpected key: %s", buffer);
|
||||
}
|
||||
|
||||
if (!found[0] || !found[1] || !found[2])
|
||||
ThrowError("did not find all keys");
|
||||
}
|
||||
CloseHandle(keys);
|
||||
|
||||
PrintToServer("All tests passed!");
|
||||
CloseHandle(trie);
|
||||
return Plugin_Handled;
|
||||
|
||||
Reference in New Issue
Block a user