I present to you this include file with stocks for recursive tries(tries inside of tries inside of tries) that iteration Handle is auto updated when trie is(that's if you use the stocks).
Stocks:
PHP Code:
/*
* This stock creates a new iteratable trie.
* @keyNameSize Size of keyNames array.
* @forceNoChild Should CheckForChildren skip it's check and just false.
* @forceProtectFalse Should we skip FreeChildren's leak protection.
* @return A handle to newly created iteratable trie, otherwise, it returns INVALID_HANDLE.
*/
stock Handle:CreateIterTrie(keyNameSize, bool:forceNoChild = false, bool:forceProtectFalse = false);
/*
* Inserts a value into an iteratable trie.
* @trie Trie to add to.
* @entry Keyname to store item as.
* @item Item to store.
* @return True on success, false otherwise.
*/
stock bool:InsertValueIntoTrie(Handle:trie, const String:entry[], any:item);
/*
* Inserts a string into an iteratable trie.
* @trie Trie to add to.
* @entry Keyname to store item as.
* @item String to store.
* @return True on success, false otherwise.
*/
stock bool:InsertStringIntoTrie(Handle:trie, const String:entry[], const String:item[]);
/*
* Inserts an array into an iteratable trie.
* @trie Trie to add to.
* @entry Keyname to store item as.
* @item Array to store.
* @return True on success, false otherwise.
*/
stock bool:InsertArrayIntoTrie(Handle:trie, const String:entry[], const any:item[]);
/*
* Creates a new trie and inserts it into a parent trie.
* Parent trie has to be iteratable.
* @parent Parent trie to store into.
* @entry Keyname to store as.
* @return Handle to new trie, INVALID_HANDLE if insertion failed.
*/
stock Handle:InsertNewTrie(Handle:parent, const String:entry[]);
/*
* Creates a new iteratable trie and inserts it into a parent trie.
* Parent trie has to be iteratable.
* @parent Parent trie to store into.
* @entry Keyname to store as.
* @keyNameSize Size of keyNames array.
* @forceNoChild Should CheckForChildren skip it's check and just false.
* @forceProtectFalse Should we skip FreeChildren's leak protection.
* @return Handle to new trie, INVALID_HANDLE if insertion failed or trie failed to be made.
*/
stock Handle:InsertNewIterTrie(Handle:parent, const String:entry[], keyNameSize, bool:forceNoChild = false, bool:forceProtectFalse = false);
/*
* This stock is for checking if a trie has children, an iteratable and non-iteratable trie can be passed.
* Used mostly internally.
* @trieCheck The trie to check for children.
* @return True if it has children, false if otherwise.
*/
stock bool:CheckForChildren(Handle:trieCheck);
/*
* This stock will fail if it was passed a non-iteratable trie, this is for recursivily freeing tries stored into it.
* Note: Use this in an if statement with CheckForChildren()
* Used mostly internally.
* @trie Trie to free children and itself as.
* @keyNameLength Max string size to be expected for keynames in ADT array.
* @noreturn
*/
stock FreeChildren(Handle:trie, keyNameLength);
/*
* This starts recursive freeing starting with trie passed.
* This also checks if passed trie can be recursed freed.
* @trie Trie to begin recursive freeing on.
* @keyNameLength Length of keyName strings.
* @noreturn
*/
stock RecursiveFree(&Handle:trie, keyNameLength);
ChangeLog:
Quote:
1.01.11.2- Changed SetFailure to SetFailState (I had a SetFailure function in the code I made this for).
- Removed unused parameters
- Cleaned up code.
1.3- Made this into a full blown include file, changed thread name.
1.41.4- Removed warning.
- Fixed compile issue.
1.51.6- Renamed some stocks
- Added 2 more stocks
- Added some more parameters to some stocks.
|