arrayObject.cpp
Engine/source/console/arrayObject.cpp
Public Functions
ConsoleDocClass(ArrayObject , "@brief Data structure <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> storing indexed sequences of key/<a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">pairs.\n\n</a>" "This is <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> powerful array class providing PHP style arrays in <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">TorqueScript.\n\n</a>" "The following features are supported:<ul>\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "<li>array pointers: this allows you <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> move forwards or backwards through " "the array as <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> it was <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> list, including jumping <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the start or end.</li >\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "< li >sorting:the array can be sorted in either alphabetic or numeric mode, " "on the key or the value, and in ascending or descending order</li >\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "< li >add/remove elements:elements can be pushed/popped from the start or " "end of the array, or can be inserted/erased from anywhere in the middle</li >\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "< li >removal of duplicates:remove duplicate keys or duplicate values</li >\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "< li >searching:search the array and return the index of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> particular key or " "<a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a></li >\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "< li >counting:count the number of instaces of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> particular <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> or key in " "the array, as well as the total number of elements</li >\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "< li >advanced features:array append, array crop and array duplicate</li >\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "</ul >\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "<a href="/coding/file/platformmemory_8cpp/#platformmemory_8cpp_1a3ffd6d180bfa999dfbafef07fab77f2caf8303e03242532eebd970f40ee509689">Array</a> element keys and values can be strings or <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">numbers\n\n</a>" " @ingroup Scripting" )
DefineEngineMethod(ArrayObject , add , void , (const char *key, const char *value) , ("") , "Adds <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> element <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the end of an array (same as push_back()).\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@param key Key <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">element\n</a>" "@param <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/document_8h/#document_8h_1a071cf97155ba72ac9a1fc4ad7e63d481">Value</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">element\n</a>" )
DefineEngineMethod(ArrayObject , append , bool , (ArrayObject *target) , "Appends the target array <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the array <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">object.\n</a>" "@param target <a href="/coding/class/classarrayobject/">ArrayObject</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> append <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the end of this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">array\n</a>" )
DefineEngineMethod(ArrayObject , count , S32 , () , "Get the number of elements in the array." )
DefineEngineMethod(ArrayObject , countKey , S32 , (const char *key) , "Get the number of times <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> particular key is found in the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">array.\n</a>" "@param key Key <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">count\n</a>" )
DefineEngineMethod(ArrayObject , countValue , S32 , (const char *value) , "Get the number of times <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> particular <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> is found in the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">array.\n</a>" "@param <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/platformmemory_8cpp/#platformmemory_8cpp_1a3ffd6d180bfa999dfbafef07fab77f2caf8303e03242532eebd970f40ee509689">Array</a> element <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">count\n</a>" )
DefineEngineMethod(ArrayObject , crop , bool , (ArrayObject *target) , "Removes elements with matching keys from <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">array.\n</a>" "@param target <a href="/coding/class/classarrayobject/">ArrayObject</a> containing keys <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> remove from this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">array\n</a>" )
DefineEngineMethod(ArrayObject , duplicate , bool , (ArrayObject *target) , "Alters array into an exact duplicate of the target <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">array.\n</a>" "@param target <a href="/coding/class/classarrayobject/">ArrayObject</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">duplicate\n</a>" )
DefineEngineMethod(ArrayObject , echo , void , () , "Echos the array contents <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the console" )
DefineEngineMethod(ArrayObject , empty , void , () , "Emptys all elements from an array" )
DefineEngineMethod(ArrayObject , erase , void , (S32 index) , "Removes an element at <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> specific position from the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">array.\n</a>" "@param index 0-based index of the element <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">remove\n</a>" )
DefineEngineMethod(ArrayObject , getCurrent , S32 , () , "Gets the current <a href="/coding/file/pointer_8h/#pointer_8h_1aae1f8d263916ad71bd415381591549c0">pointer</a> index" )
DefineEngineMethod(ArrayObject , getIndexFromKey , S32 , (const char *key) , "Search the array from the current position <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the key " "@param <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/platformmemory_8cpp/#platformmemory_8cpp_1a3ffd6d180bfa999dfbafef07fab77f2caf8303e03242532eebd970f40ee509689">Array</a> key <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> search <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">for\n</a>" "@return Index of the first element found, or -1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">none\n</a>" )
DefineEngineMethod(ArrayObject , getIndexFromValue , S32 , (const char *value) , "Search the array from the current position <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the element " "@param <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/platformmemory_8cpp/#platformmemory_8cpp_1a3ffd6d180bfa999dfbafef07fab77f2caf8303e03242532eebd970f40ee509689">Array</a> <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> search <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">for\n</a>" "@return Index of the first element found, or -1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">none\n</a>" )
DefineEngineMethod(ArrayObject , getKey , const char * , (S32 index) , "Get the key of the array element at the submitted <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">index.\n</a>" "@param index 0-based index of the array element <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">get\n</a>" "@return The key associated with the array element at the " "specified index, or \"\" <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the index is out of <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">range\n</a>" )
DefineEngineMethod(ArrayObject , getValue , const char * , (S32 index) , "Get the <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> of the array element at the submitted <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">index.\n</a>" "@param index 0-based index of the array element <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">get\n</a>" "@return The <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> of the array element at the specified index, " "or \"\" <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the index is out of <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">range\n</a>" )
DefineEngineMethod(ArrayObject , insert , void , (const char *key, const char *value, S32 index) )
DefineEngineMethod(ArrayObject , moveFirst , S32 , () , "Moves array <a href="/coding/file/pointer_8h/#pointer_8h_1aae1f8d263916ad71bd415381591549c0">pointer</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> start of <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">array\n\n</a>" "@return Returns the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> array <a href="/coding/file/pointer_8h/#pointer_8h_1aae1f8d263916ad71bd415381591549c0">pointer</a>" )
DefineEngineMethod(ArrayObject , moveLast , S32 , () , "Moves array <a href="/coding/file/pointer_8h/#pointer_8h_1aae1f8d263916ad71bd415381591549c0">pointer</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> end of <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">array\n\n</a>" "@return Returns the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> array <a href="/coding/file/pointer_8h/#pointer_8h_1aae1f8d263916ad71bd415381591549c0">pointer</a>" )
DefineEngineMethod(ArrayObject , moveNext , S32 , () , "Moves array <a href="/coding/file/pointer_8h/#pointer_8h_1aae1f8d263916ad71bd415381591549c0">pointer</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> next <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">position\n\n</a>" "@return Returns the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> array pointer, or -1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> already at the end" )
DefineEngineMethod(ArrayObject , movePrev , S32 , () , "Moves array <a href="/coding/file/pointer_8h/#pointer_8h_1aae1f8d263916ad71bd415381591549c0">pointer</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> prev <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">position\n\n</a>" "@return Returns the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> array pointer, or -1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> already at the start" )
DefineEngineMethod(ArrayObject , pop_back , void , () , "Removes the last element from the array" )
DefineEngineMethod(ArrayObject , pop_front , void , () , "Removes the first element from the array" )
DefineEngineMethod(ArrayObject , push_back , void , (const char *key, const char *value) , ("") , "Adds <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> element <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the end of an <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">array.\n</a>" "@param key Key <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">element\n</a>" "@param <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/document_8h/#document_8h_1a071cf97155ba72ac9a1fc4ad7e63d481">Value</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">element\n</a>" )
DefineEngineMethod(ArrayObject , push_front , void , (const char *key, const char *value) , ("") , "Adds <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> element <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the front of an array" )
DefineEngineMethod(ArrayObject , setCurrent , void , (S32 index) , "Sets the current <a href="/coding/file/pointer_8h/#pointer_8h_1aae1f8d263916ad71bd415381591549c0">pointer</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">index.\n</a>" "@param index New 0-based <a href="/coding/file/pointer_8h/#pointer_8h_1aae1f8d263916ad71bd415381591549c0">pointer</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">index\n</a>" )
DefineEngineMethod(ArrayObject , setKey , void , (const char *key, S32 index) , "Set the key at the given <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">index.\n</a>" "@param key New key <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">value\n</a>" "@param index 0-based index of the array element <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">update\n</a>" )
DefineEngineMethod(ArrayObject , setValue , void , (const char *value, S32 index) , "Set the <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> at the given <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">index.\n</a>" "@param <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> New array element <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">value\n</a>" "@param index 0-based index of the array element <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">update\n</a>" )
DefineEngineMethod(ArrayObject , sort , void , (bool ascending) , (false) , "Alpha sorts the array by <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">value\n\n</a>" "@param ascending True <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> ascending sort, false <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> descending <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">sort\n</a>" )
DefineEngineMethod(ArrayObject , sorta , void , () , "Alpha sorts the array by <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> in ascending order" )
DefineEngineMethod(ArrayObject , sortd , void , () , "Alpha sorts the array by <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> in descending order" )
DefineEngineMethod(ArrayObject , sortf , void , (const char *functionName) , "Sorts the array by <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> in ascending order using the given callback <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">function.\n</a>" "@param functionName Name of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> function that takes two arguments A and B and returns -1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> A is less, 1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> B is less, and 0 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> both are <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">equal.\n\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "function mySortCallback(%<a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a>, %<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a>)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " return strcmp(%a.name, %b.name);\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "}\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "%array.sortf(\"mySortCallback\" );\n" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n</a>" )
DefineEngineMethod(ArrayObject , sortfd , void , (const char *functionName) , "Sorts the array by <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> in descending order using the given callback <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">function.\n</a>" "@param functionName Name of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> function that takes two arguments A and B and returns -1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> A is less, 1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> B is less, and 0 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> both are equal." " @see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">sortf\n</a>" )
DefineEngineMethod(ArrayObject , sortfk , void , (const char *functionName) , "Sorts the array by key in ascending order using the given callback <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">function.\n</a>" "@param functionName Name of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> function that takes two arguments A and B and returns -1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> A is less, 1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> B is less, and 0 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> both are equal." " @see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">sortf\n</a>" )
DefineEngineMethod(ArrayObject , sortfkd , void , (const char *functionName) , "Sorts the array by key in descending order using the given callback <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">function.\n</a>" "@param functionName Name of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> function that takes two arguments A and B and returns -1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> A is less, 1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> B is less, and 0 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> both are equal." " @see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">sortf\n</a>" )
DefineEngineMethod(ArrayObject , sortk , void , (bool ascending) , (false) , "Alpha sorts the array by <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">key\n\n</a>" "@param ascending True <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> ascending sort, false <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> descending <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">sort\n</a>" )
DefineEngineMethod(ArrayObject , sortka , void , () , "Alpha sorts the array by key in ascending order" )
DefineEngineMethod(ArrayObject , sortkd , void , () , "Alpha sorts the array by key in descending order" )
DefineEngineMethod(ArrayObject , sortn , void , (bool ascending) , (false) , "Numerically sorts the array by <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">value\n\n</a>" "@param ascending True <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> ascending sort, false <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> descending <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">sort\n</a>" )
DefineEngineMethod(ArrayObject , sortna , void , () , "Numerically sorts the array by <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> in ascending order" )
DefineEngineMethod(ArrayObject , sortnd , void , () , "Numerically sorts the array by <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> in descending order" )
DefineEngineMethod(ArrayObject , sortnk , void , (bool ascending) , (false) , "Numerically sorts the array by <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">key\n\n</a>" "@param ascending True <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> ascending sort, false <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> descending <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">sort\n</a>" )
DefineEngineMethod(ArrayObject , sortnka , void , () , "Numerical sorts the array by key in ascending order" )
DefineEngineMethod(ArrayObject , sortnkd , void , () , "Numerical sorts the array by key in descending order" )
DefineEngineMethod(ArrayObject , uniqueKey , void , () , "Removes any elements that have duplicated keys (leaving the first instance)" )
DefineEngineMethod(ArrayObject , uniqueValue , void , () , "Removes any elements that have duplicated values (leaving the first instance)" )
Detailed Description
Public Functions
ConsoleDocClass(ArrayObject , "@brief Data structure <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> storing indexed sequences of key/<a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">pairs.\n\n</a>" "This is <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> powerful array class providing PHP style arrays in <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">TorqueScript.\n\n</a>" "The following features are supported:<ul>\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "<li>array pointers: this allows you <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> move forwards or backwards through " "the array as <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> it was <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> list, including jumping <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the start or end.</li >\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "< li >sorting:the array can be sorted in either alphabetic or numeric mode, " "on the key or the value, and in ascending or descending order</li >\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "< li >add/remove elements:elements can be pushed/popped from the start or " "end of the array, or can be inserted/erased from anywhere in the middle</li >\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "< li >removal of duplicates:remove duplicate keys or duplicate values</li >\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "< li >searching:search the array and return the index of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> particular key or " "<a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a></li >\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "< li >counting:count the number of instaces of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> particular <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> or key in " "the array, as well as the total number of elements</li >\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "< li >advanced features:array append, array crop and array duplicate</li >\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "</ul >\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "<a href="/coding/file/platformmemory_8cpp/#platformmemory_8cpp_1a3ffd6d180bfa999dfbafef07fab77f2caf8303e03242532eebd970f40ee509689">Array</a> element keys and values can be strings or <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">numbers\n\n</a>" " @ingroup Scripting" )
DefineEngineMethod(ArrayObject , add , void , (const char *key, const char *value) , ("") , "Adds <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> element <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the end of an array (same as push_back()).\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@param key Key <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">element\n</a>" "@param <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/document_8h/#document_8h_1a071cf97155ba72ac9a1fc4ad7e63d481">Value</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">element\n</a>" )
DefineEngineMethod(ArrayObject , append , bool , (ArrayObject *target) , "Appends the target array <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the array <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">object.\n</a>" "@param target <a href="/coding/class/classarrayobject/">ArrayObject</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> append <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the end of this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">array\n</a>" )
DefineEngineMethod(ArrayObject , count , S32 , () , "Get the number of elements in the array." )
DefineEngineMethod(ArrayObject , countKey , S32 , (const char *key) , "Get the number of times <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> particular key is found in the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">array.\n</a>" "@param key Key <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">count\n</a>" )
DefineEngineMethod(ArrayObject , countValue , S32 , (const char *value) , "Get the number of times <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> particular <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> is found in the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">array.\n</a>" "@param <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/platformmemory_8cpp/#platformmemory_8cpp_1a3ffd6d180bfa999dfbafef07fab77f2caf8303e03242532eebd970f40ee509689">Array</a> element <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">count\n</a>" )
DefineEngineMethod(ArrayObject , crop , bool , (ArrayObject *target) , "Removes elements with matching keys from <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">array.\n</a>" "@param target <a href="/coding/class/classarrayobject/">ArrayObject</a> containing keys <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> remove from this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">array\n</a>" )
DefineEngineMethod(ArrayObject , duplicate , bool , (ArrayObject *target) , "Alters array into an exact duplicate of the target <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">array.\n</a>" "@param target <a href="/coding/class/classarrayobject/">ArrayObject</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">duplicate\n</a>" )
DefineEngineMethod(ArrayObject , echo , void , () , "Echos the array contents <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the console" )
DefineEngineMethod(ArrayObject , empty , void , () , "Emptys all elements from an array" )
DefineEngineMethod(ArrayObject , erase , void , (S32 index) , "Removes an element at <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> specific position from the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">array.\n</a>" "@param index 0-based index of the element <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">remove\n</a>" )
DefineEngineMethod(ArrayObject , getCurrent , S32 , () , "Gets the current <a href="/coding/file/pointer_8h/#pointer_8h_1aae1f8d263916ad71bd415381591549c0">pointer</a> index" )
DefineEngineMethod(ArrayObject , getIndexFromKey , S32 , (const char *key) , "Search the array from the current position <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the key " "@param <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/platformmemory_8cpp/#platformmemory_8cpp_1a3ffd6d180bfa999dfbafef07fab77f2caf8303e03242532eebd970f40ee509689">Array</a> key <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> search <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">for\n</a>" "@return Index of the first element found, or -1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">none\n</a>" )
DefineEngineMethod(ArrayObject , getIndexFromValue , S32 , (const char *value) , "Search the array from the current position <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the element " "@param <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/platformmemory_8cpp/#platformmemory_8cpp_1a3ffd6d180bfa999dfbafef07fab77f2caf8303e03242532eebd970f40ee509689">Array</a> <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> search <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">for\n</a>" "@return Index of the first element found, or -1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">none\n</a>" )
DefineEngineMethod(ArrayObject , getKey , const char * , (S32 index) , "Get the key of the array element at the submitted <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">index.\n</a>" "@param index 0-based index of the array element <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">get\n</a>" "@return The key associated with the array element at the " "specified index, or \"\" <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the index is out of <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">range\n</a>" )
DefineEngineMethod(ArrayObject , getValue , const char * , (S32 index) , "Get the <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> of the array element at the submitted <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">index.\n</a>" "@param index 0-based index of the array element <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">get\n</a>" "@return The <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> of the array element at the specified index, " "or \"\" <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the index is out of <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">range\n</a>" )
DefineEngineMethod(ArrayObject , insert , void , (const char *key, const char *value, S32 index) )
DefineEngineMethod(ArrayObject , moveFirst , S32 , () , "Moves array <a href="/coding/file/pointer_8h/#pointer_8h_1aae1f8d263916ad71bd415381591549c0">pointer</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> start of <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">array\n\n</a>" "@return Returns the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> array <a href="/coding/file/pointer_8h/#pointer_8h_1aae1f8d263916ad71bd415381591549c0">pointer</a>" )
DefineEngineMethod(ArrayObject , moveLast , S32 , () , "Moves array <a href="/coding/file/pointer_8h/#pointer_8h_1aae1f8d263916ad71bd415381591549c0">pointer</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> end of <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">array\n\n</a>" "@return Returns the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> array <a href="/coding/file/pointer_8h/#pointer_8h_1aae1f8d263916ad71bd415381591549c0">pointer</a>" )
DefineEngineMethod(ArrayObject , moveNext , S32 , () , "Moves array <a href="/coding/file/pointer_8h/#pointer_8h_1aae1f8d263916ad71bd415381591549c0">pointer</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> next <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">position\n\n</a>" "@return Returns the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> array pointer, or -1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> already at the end" )
DefineEngineMethod(ArrayObject , movePrev , S32 , () , "Moves array <a href="/coding/file/pointer_8h/#pointer_8h_1aae1f8d263916ad71bd415381591549c0">pointer</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> prev <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">position\n\n</a>" "@return Returns the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> array pointer, or -1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> already at the start" )
DefineEngineMethod(ArrayObject , pop_back , void , () , "Removes the last element from the array" )
DefineEngineMethod(ArrayObject , pop_front , void , () , "Removes the first element from the array" )
DefineEngineMethod(ArrayObject , push_back , void , (const char *key, const char *value) , ("") , "Adds <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> element <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the end of an <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">array.\n</a>" "@param key Key <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">element\n</a>" "@param <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/document_8h/#document_8h_1a071cf97155ba72ac9a1fc4ad7e63d481">Value</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">element\n</a>" )
DefineEngineMethod(ArrayObject , push_front , void , (const char *key, const char *value) , ("") , "Adds <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> element <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the front of an array" )
DefineEngineMethod(ArrayObject , setCurrent , void , (S32 index) , "Sets the current <a href="/coding/file/pointer_8h/#pointer_8h_1aae1f8d263916ad71bd415381591549c0">pointer</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">index.\n</a>" "@param index New 0-based <a href="/coding/file/pointer_8h/#pointer_8h_1aae1f8d263916ad71bd415381591549c0">pointer</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">index\n</a>" )
DefineEngineMethod(ArrayObject , setKey , void , (const char *key, S32 index) , "Set the key at the given <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">index.\n</a>" "@param key New key <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">value\n</a>" "@param index 0-based index of the array element <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">update\n</a>" )
DefineEngineMethod(ArrayObject , setValue , void , (const char *value, S32 index) , "Set the <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> at the given <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">index.\n</a>" "@param <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> New array element <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">value\n</a>" "@param index 0-based index of the array element <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">update\n</a>" )
DefineEngineMethod(ArrayObject , sort , void , (bool ascending) , (false) , "Alpha sorts the array by <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">value\n\n</a>" "@param ascending True <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> ascending sort, false <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> descending <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">sort\n</a>" )
DefineEngineMethod(ArrayObject , sorta , void , () , "Alpha sorts the array by <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> in ascending order" )
DefineEngineMethod(ArrayObject , sortd , void , () , "Alpha sorts the array by <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> in descending order" )
DefineEngineMethod(ArrayObject , sortf , void , (const char *functionName) , "Sorts the array by <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> in ascending order using the given callback <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">function.\n</a>" "@param functionName Name of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> function that takes two arguments A and B and returns -1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> A is less, 1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> B is less, and 0 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> both are <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">equal.\n\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "function mySortCallback(%<a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a>, %<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a>)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " return strcmp(%a.name, %b.name);\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "}\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "%array.sortf(\"mySortCallback\" );\n" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n</a>" )
DefineEngineMethod(ArrayObject , sortfd , void , (const char *functionName) , "Sorts the array by <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> in descending order using the given callback <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">function.\n</a>" "@param functionName Name of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> function that takes two arguments A and B and returns -1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> A is less, 1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> B is less, and 0 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> both are equal." " @see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">sortf\n</a>" )
DefineEngineMethod(ArrayObject , sortfk , void , (const char *functionName) , "Sorts the array by key in ascending order using the given callback <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">function.\n</a>" "@param functionName Name of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> function that takes two arguments A and B and returns -1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> A is less, 1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> B is less, and 0 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> both are equal." " @see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">sortf\n</a>" )
DefineEngineMethod(ArrayObject , sortfkd , void , (const char *functionName) , "Sorts the array by key in descending order using the given callback <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">function.\n</a>" "@param functionName Name of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> function that takes two arguments A and B and returns -1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> A is less, 1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> B is less, and 0 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> both are equal." " @see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">sortf\n</a>" )
DefineEngineMethod(ArrayObject , sortk , void , (bool ascending) , (false) , "Alpha sorts the array by <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">key\n\n</a>" "@param ascending True <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> ascending sort, false <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> descending <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">sort\n</a>" )
DefineEngineMethod(ArrayObject , sortka , void , () , "Alpha sorts the array by key in ascending order" )
DefineEngineMethod(ArrayObject , sortkd , void , () , "Alpha sorts the array by key in descending order" )
DefineEngineMethod(ArrayObject , sortn , void , (bool ascending) , (false) , "Numerically sorts the array by <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">value\n\n</a>" "@param ascending True <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> ascending sort, false <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> descending <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">sort\n</a>" )
DefineEngineMethod(ArrayObject , sortna , void , () , "Numerically sorts the array by <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> in ascending order" )
DefineEngineMethod(ArrayObject , sortnd , void , () , "Numerically sorts the array by <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> in descending order" )
DefineEngineMethod(ArrayObject , sortnk , void , (bool ascending) , (false) , "Numerically sorts the array by <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">key\n\n</a>" "@param ascending True <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> ascending sort, false <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> descending <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">sort\n</a>" )
DefineEngineMethod(ArrayObject , sortnka , void , () , "Numerical sorts the array by key in ascending order" )
DefineEngineMethod(ArrayObject , sortnkd , void , () , "Numerical sorts the array by key in descending order" )
DefineEngineMethod(ArrayObject , uniqueKey , void , () , "Removes any elements that have duplicated keys (leaving the first instance)" )
DefineEngineMethod(ArrayObject , uniqueValue , void , () , "Removes any elements that have duplicated values (leaving the first instance)" )
IMPLEMENT_CONOBJECT(ArrayObject )
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#include "platform/platform.h" 25#include "console/arrayObject.h" 26#include "console/consoleTypes.h" 27#include "console/engineAPI.h" 28#include "math/mMathFn.h" 29 30 31IMPLEMENT_CONOBJECT(ArrayObject); 32 33ConsoleDocClass( ArrayObject, 34 "@brief Data structure for storing indexed sequences of key/value pairs.\n\n" 35 36 "This is a powerful array class providing PHP style arrays in TorqueScript.\n\n" 37 38 "The following features are supported:<ul>\n" 39 "<li>array pointers: this allows you to move forwards or backwards through " 40 "the array as if it was a list, including jumping to the start or end.</li>\n" 41 "<li>sorting: the array can be sorted in either alphabetic or numeric mode, " 42 "on the key or the value, and in ascending or descending order</li>\n" 43 "<li>add/remove elements: elements can be pushed/popped from the start or " 44 "end of the array, or can be inserted/erased from anywhere in the middle</li>\n" 45 "<li>removal of duplicates: remove duplicate keys or duplicate values</li>\n" 46 "<li>searching: search the array and return the index of a particular key or " 47 "value</li>\n" 48 "<li>counting: count the number of instaces of a particular value or key in " 49 "the array, as well as the total number of elements</li>\n" 50 "<li>advanced features: array append, array crop and array duplicate</li>\n" 51 "</ul>\n\n" 52 53 "Array element keys and values can be strings or numbers\n\n" 54 55 "@ingroup Scripting" 56); 57 58 59bool ArrayObject::smDecreasing = false; 60bool ArrayObject::smCaseSensitive = false; 61const char* ArrayObject::smCompareFunction; 62 63 64S32 QSORT_CALLBACK ArrayObject::_valueCompare( const void* a, const void* b ) 65{ 66 ArrayObject::Element *ea = (ArrayObject::Element *) (a); 67 ArrayObject::Element *eb = (ArrayObject::Element *) (b); 68 S32 result = smCaseSensitive ? dStrnatcmp(ea->value, eb->value) : dStrnatcasecmp(ea->value, eb->value); 69 return ( smDecreasing ? -result : result ); 70} 71 72S32 QSORT_CALLBACK ArrayObject::_valueNumCompare( const void* a, const void* b ) 73{ 74 ArrayObject::Element *ea = (ArrayObject::Element *) (a); 75 ArrayObject::Element *eb = (ArrayObject::Element *) (b); 76 F32 aCol = dAtof(ea->value); 77 F32 bCol = dAtof(eb->value); 78 F32 result = aCol - bCol; 79 S32 res = result < 0 ? -1 : (result > 0 ? 1 : 0); 80 return ( smDecreasing ? -res : res ); 81} 82 83S32 QSORT_CALLBACK ArrayObject::_keyCompare( const void* a, const void* b ) 84{ 85 ArrayObject::Element *ea = (ArrayObject::Element *) (a); 86 ArrayObject::Element *eb = (ArrayObject::Element *) (b); 87 S32 result = smCaseSensitive ? dStrnatcmp(ea->key, eb->key) : dStrnatcasecmp(ea->key, eb->key); 88 return ( smDecreasing ? -result : result ); 89} 90 91S32 QSORT_CALLBACK ArrayObject::_keyNumCompare( const void* a, const void* b ) 92{ 93 ArrayObject::Element *ea = (ArrayObject::Element *) (a); 94 ArrayObject::Element *eb = (ArrayObject::Element *) (b); 95 const char* aCol = ea->key; 96 const char* bCol = eb->key; 97 F32 result = dAtof(aCol) - dAtof(bCol); 98 S32 res = result < 0 ? -1 : (result > 0 ? 1 : 0); 99 return ( smDecreasing ? -res : res ); 100} 101 102S32 QSORT_CALLBACK ArrayObject::_keyFunctionCompare( const void* a, const void* b ) 103{ 104 ArrayObject::Element* ea = ( ArrayObject::Element* )( a ); 105 ArrayObject::Element* eb = ( ArrayObject::Element* )( b ); 106 107 S32 result = dAtoi(Con::executef((const char*)smCompareFunction, ea->key, eb->key)); 108 S32 res = result < 0 ? -1 : ( result > 0 ? 1 : 0 ); 109 return ( smDecreasing ? -res : res ); 110} 111 112S32 QSORT_CALLBACK ArrayObject::_valueFunctionCompare( const void* a, const void* b ) 113{ 114 ArrayObject::Element* ea = ( ArrayObject::Element* )( a ); 115 ArrayObject::Element* eb = ( ArrayObject::Element* )( b ); 116 117 S32 result = dAtoi( Con::executef( (const char*)smCompareFunction, ea->value, eb->value ) ); 118 S32 res = result < 0 ? -1 : ( result > 0 ? 1 : 0 ); 119 return ( smDecreasing ? -res : res ); 120} 121 122 123//----------------------------------------------------------------------------- 124 125ArrayObject::ArrayObject() 126 : mCaseSensitive( false ), 127 mCurrentIndex( NULL ) 128{ 129} 130 131//----------------------------------------------------------------------------- 132 133void ArrayObject::initPersistFields() 134{ 135 addField( "caseSensitive", TypeBool, Offset( mCaseSensitive, ArrayObject ), 136 "Makes the keys and values case-sensitive.\n" 137 "By default, comparison of key and value strings will be case-insensitive." ); 138 139 addProtectedField( "key", TypeCaseString, NULL, &_addKeyFromField, &emptyStringProtectedGetFn, 140 "Helper field which allows you to add new key['keyname'] = value pairs." ); 141 142 Parent::initPersistFields(); 143} 144 145//----------------------------------------------------------------------------- 146 147bool ArrayObject::_addKeyFromField( void *object, const char *index, const char *data ) 148{ 149 static_cast<ArrayObject*>( object )->push_back( index, data ); 150 return false; 151} 152 153//----------------------------------------------------------------------------- 154 155S32 ArrayObject::getIndexFromValue( const String &value ) const 156{ 157 S32 foundIndex = -1; 158 for ( S32 i = mCurrentIndex; i < mArray.size(); i++ ) 159 { 160 if ( isEqual( mArray[i].value, value ) ) 161 { 162 foundIndex = i; 163 break; 164 } 165 } 166 167 if( foundIndex < 0 ) 168 { 169 for ( S32 i = 0; i < mCurrentIndex; i++ ) 170 { 171 if ( isEqual( mArray[i].value, value ) ) 172 { 173 foundIndex = i; 174 break; 175 } 176 } 177 } 178 179 return foundIndex; 180} 181 182//----------------------------------------------------------------------------- 183 184S32 ArrayObject::getIndexFromKey( const String &key ) const 185{ 186 S32 foundIndex = -1; 187 for ( S32 i = mCurrentIndex; i < mArray.size(); i++ ) 188 { 189 if ( isEqual( mArray[i].key, key ) ) 190 { 191 foundIndex = i; 192 break; 193 } 194 } 195 196 if( foundIndex < 0 ) 197 { 198 for ( S32 i = 0; i < mCurrentIndex; i++ ) 199 { 200 if ( isEqual( mArray[i].key, key ) ) 201 { 202 foundIndex = i; 203 break; 204 } 205 } 206 } 207 208 return foundIndex; 209} 210 211//----------------------------------------------------------------------------- 212 213S32 ArrayObject::getIndexFromKeyValue( const String &key, const String &value ) const 214{ 215 S32 foundIndex = -1; 216 for ( S32 i = mCurrentIndex; i < mArray.size(); i++ ) 217 { 218 if ( isEqual( mArray[i].key, key ) && isEqual( mArray[i].value, value ) ) 219 { 220 foundIndex = i; 221 break; 222 } 223 } 224 225 if ( foundIndex < 0 ) 226 { 227 for ( S32 i = 0; i < mCurrentIndex; i++ ) 228 { 229 if ( isEqual( mArray[i].key, key ) && isEqual( mArray[i].value, value ) ) 230 { 231 foundIndex = i; 232 break; 233 } 234 } 235 } 236 237 return foundIndex; 238} 239 240//----------------------------------------------------------------------------- 241 242const String& ArrayObject::getKeyFromIndex( S32 index ) const 243{ 244 if ( index >= mArray.size() || index < 0 ) 245 return String::EmptyString; 246 247 return mArray[index].key; 248} 249 250//----------------------------------------------------------------------------- 251 252const String& ArrayObject::getValueFromIndex( S32 index ) const 253{ 254 if( index >= mArray.size() || index < 0 ) 255 return String::EmptyString; 256 257 return mArray[index].value; 258} 259 260//----------------------------------------------------------------------------- 261 262S32 ArrayObject::countValue( const String &value ) const 263{ 264 S32 count = 0; 265 for ( S32 i = 0; i < mArray.size(); i++ ) 266 { 267 if ( isEqual( mArray[i].value, value ) ) 268 count++; 269 } 270 271 return count; 272} 273 274//----------------------------------------------------------------------------- 275 276S32 ArrayObject::countKey( const String &key) const 277{ 278 S32 count = 0; 279 for ( S32 i = 0; i < mArray.size(); i++ ) 280 { 281 if ( isEqual( mArray[i].key, key ) ) 282 count++; 283 } 284 285 return count; 286} 287 288//----------------------------------------------------------------------------- 289 290void ArrayObject::push_back( const String &key, const String &value ) 291{ 292 mArray.push_back( Element( key, value ) ); 293} 294 295//----------------------------------------------------------------------------- 296 297void ArrayObject::push_front( const String &key, const String &value ) 298{ 299 mArray.push_front( Element( key, value ) ); 300} 301 302//----------------------------------------------------------------------------- 303 304void ArrayObject::insert( const String &key, const String &value, S32 index ) 305{ 306 index = mClamp( index, 0, mArray.size() ); 307 mArray.insert( index, Element( key, value ) ); 308} 309 310//----------------------------------------------------------------------------- 311 312void ArrayObject::pop_back() 313{ 314 if(mArray.size() <= 0) 315 return; 316 317 mArray.pop_back(); 318 319 if( mCurrentIndex >= mArray.size() ) 320 mCurrentIndex = mArray.size() - 1; 321} 322 323//----------------------------------------------------------------------------- 324 325void ArrayObject::pop_front() 326{ 327 if( mArray.size() <= 0 ) 328 return; 329 330 mArray.pop_front(); 331 332 if( mCurrentIndex >= mArray.size() ) 333 mCurrentIndex = mArray.size() - 1; 334} 335 336//----------------------------------------------------------------------------- 337 338void ArrayObject::erase( S32 index ) 339{ 340 if(index < 0 || index >= mArray.size()) 341 return; 342 343 mArray.erase( index ); 344} 345 346//----------------------------------------------------------------------------- 347 348void ArrayObject::empty() 349{ 350 mArray.clear(); 351 mCurrentIndex = 0; 352} 353 354//----------------------------------------------------------------------------- 355 356void ArrayObject::moveIndex(S32 prev, S32 index) 357{ 358 if(index >= mArray.size()) 359 push_back(mArray[prev].key, mArray[prev].value); 360 else 361 mArray[index] = mArray[prev]; 362 mArray[prev].value = String::EmptyString; 363 mArray[prev].key = String::EmptyString; 364} 365 366//----------------------------------------------------------------------------- 367 368void ArrayObject::uniqueValue() 369{ 370 for(S32 i=0; i<mArray.size(); i++) 371 { 372 for(S32 j=<a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1aa42a9a9cb6e2b93d7f825c395af871bf">i</a>+1; j<mArray.size(); j++) 373 { 374 if ( isEqual( mArray[i].value, mArray[j].value ) ) 375 { 376 erase(j); 377 j--; 378 } 379 } 380 } 381} 382 383//----------------------------------------------------------------------------- 384 385void ArrayObject::uniqueKey() 386{ 387 for(S32 i=0; i<mArray.size(); i++) 388 { 389 for(S32 j=<a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1aa42a9a9cb6e2b93d7f825c395af871bf">i</a>+1; j<mArray.size(); j++) 390 { 391 if( isEqual( mArray[i].key, mArray[j].key ) ) 392 { 393 erase(j); 394 j--; 395 } 396 } 397 } 398} 399 400//----------------------------------------------------------------------------- 401 402void ArrayObject::duplicate(ArrayObject* obj) 403{ 404 empty(); 405 for(S32 i=0; i<obj->count(); i++) 406 { 407 const String& tempval = obj->getValueFromIndex(i); 408 const String& tempkey = obj->getKeyFromIndex(i); 409 push_back(tempkey, tempval); 410 } 411 mCurrentIndex = obj->getCurrent(); 412} 413 414//----------------------------------------------------------------------------- 415 416void ArrayObject::crop( ArrayObject *obj ) 417{ 418 for( S32 i = 0; i < obj->count(); i++ ) 419 { 420 const String &tempkey = obj->getKeyFromIndex( i ); 421 for( S32 j = 0; j < mArray.size(); j++ ) 422 { 423 if( isEqual( mArray[j].key, tempkey ) ) 424 { 425 mArray.erase( j ); 426 j--; 427 } 428 } 429 } 430} 431 432//----------------------------------------------------------------------------- 433 434void ArrayObject::append(ArrayObject* obj) 435{ 436 for(S32 i=0; i<obj->count(); i++) 437 { 438 const String& tempval = obj->getValueFromIndex(i); 439 const String& tempkey = obj->getKeyFromIndex(i); 440 push_back(tempkey, tempval); 441 } 442} 443 444//----------------------------------------------------------------------------- 445 446void ArrayObject::setKey( const String &key, S32 index ) 447{ 448 if ( index >= mArray.size() ) 449 return; 450 451 mArray[index].key = key; 452} 453 454//----------------------------------------------------------------------------- 455 456void ArrayObject::setValue( const String &value, S32 index ) 457{ 458 if ( index >= mArray.size() ) 459 return; 460 461 mArray[index].value = value; 462} 463 464//----------------------------------------------------------------------------- 465 466void ArrayObject::sort( bool valsort, bool asc, bool numeric ) 467{ 468 if ( mArray.size() <= 1 ) 469 return; 470 471 smDecreasing = asc ? false : true; 472 smCaseSensitive = isCaseSensitive(); 473 474 if ( numeric ) 475 { 476 if ( valsort ) 477 dQsort( (void *)&(mArray[0]), mArray.size(), sizeof(Element), _valueNumCompare) ; 478 else 479 dQsort( (void *)&(mArray[0]), mArray.size(), sizeof(Element), _keyNumCompare ); 480 } 481 else 482 { 483 if( valsort ) 484 dQsort( (void *)&(mArray[0]), mArray.size(), sizeof(Element), _valueCompare ); 485 else 486 dQsort( (void *)&(mArray[0]), mArray.size(), sizeof(Element), _keyCompare ); 487 } 488} 489 490//----------------------------------------------------------------------------- 491 492void ArrayObject::sort( bool valsort, bool asc, const char* callbackFunctionName ) 493{ 494 if( mArray.size() <= 1 ) 495 return; 496 497 smDecreasing = asc ? false : true; 498 smCompareFunction = callbackFunctionName; 499 500 if( valsort ) 501 dQsort( ( void* ) &( mArray[ 0 ] ), mArray.size(), sizeof( Element ), _valueFunctionCompare ) ; 502 else 503 dQsort( ( void* ) &( mArray[ 0 ] ), mArray.size(), sizeof( Element ), _keyFunctionCompare ); 504 505 smCompareFunction = NULL; 506} 507 508//----------------------------------------------------------------------------- 509 510S32 ArrayObject::moveFirst() 511{ 512 mCurrentIndex = 0; 513 return mCurrentIndex; 514} 515 516//----------------------------------------------------------------------------- 517 518S32 ArrayObject::moveLast() 519{ 520 if ( mArray.empty() ) 521 mCurrentIndex = 0; 522 else 523 mCurrentIndex = mArray.size() - 1; 524 return mCurrentIndex; 525} 526 527//----------------------------------------------------------------------------- 528 529S32 ArrayObject::moveNext() 530{ 531 if ( mCurrentIndex >= mArray.size() - 1 ) 532 return -1; 533 534 mCurrentIndex++; 535 536 return mCurrentIndex; 537} 538 539//----------------------------------------------------------------------------- 540 541S32 ArrayObject::movePrev() 542{ 543 if ( mCurrentIndex <= 0 ) 544 return -1; 545 546 mCurrentIndex--; 547 548 return mCurrentIndex; 549} 550 551//----------------------------------------------------------------------------- 552 553void ArrayObject::setCurrent( S32 idx ) 554{ 555 if ( idx < 0 || idx >= mArray.size() ) 556 { 557 Con::errorf( "ArrayObject::setCurrent( %d ) is out of the array bounds!", idx ); 558 return; 559 } 560 561 mCurrentIndex = idx; 562} 563 564//----------------------------------------------------------------------------- 565 566void ArrayObject::echo() 567{ 568 Con::printf( "ArrayObject Listing:" ); 569 Con::printf( "Index Key Value" ); 570 for ( U32 i = 0; i < mArray.size(); i++ ) 571 { 572 const String& key = mArray[i].key; 573 const String& val = mArray[i].value; 574 Con::printf( "%d [%s] => %s", i, key.c_str(), val.c_str() ); 575 } 576} 577 578//============================================================================= 579// Console Methods. 580//============================================================================= 581 582DefineEngineMethod( ArrayObject, getIndexFromValue, S32, ( const char* value ),, 583 "Search the array from the current position for the element " 584 "@param value Array value to search for\n" 585 "@return Index of the first element found, or -1 if none\n" ) 586{ 587 return object->getIndexFromValue( value ); 588} 589 590DefineEngineMethod( ArrayObject, getIndexFromKey, S32, ( const char* key ),, 591 "Search the array from the current position for the key " 592 "@param value Array key to search for\n" 593 "@return Index of the first element found, or -1 if none\n" ) 594{ 595 return object->getIndexFromKey( key ); 596} 597 598DefineEngineMethod( ArrayObject, getValue, const char*, ( S32 index ),, 599 "Get the value of the array element at the submitted index.\n" 600 "@param index 0-based index of the array element to get\n" 601 "@return The value of the array element at the specified index, " 602 "or \"\" if the index is out of range\n" ) 603{ 604 return object->getValueFromIndex( index ).c_str(); 605} 606 607DefineEngineMethod( ArrayObject, getKey, const char*, ( S32 index ),, 608 "Get the key of the array element at the submitted index.\n" 609 "@param index 0-based index of the array element to get\n" 610 "@return The key associated with the array element at the " 611 "specified index, or \"\" if the index is out of range\n" ) 612{ 613 return object->getKeyFromIndex( index ).c_str(); 614} 615 616DefineEngineMethod( ArrayObject, setKey, void, ( const char* key, S32 index ),, 617 "Set the key at the given index.\n" 618 "@param key New key value\n" 619 "@param index 0-based index of the array element to update\n" ) 620{ 621 object->setKey( key, index ); 622} 623 624DefineEngineMethod( ArrayObject, setValue, void, ( const char* value, S32 index ),, 625 "Set the value at the given index.\n" 626 "@param value New array element value\n" 627 "@param index 0-based index of the array element to update\n" ) 628{ 629 object->setValue( value, index ); 630} 631 632DefineEngineMethod( ArrayObject, count, S32, (),, 633 "Get the number of elements in the array." ) 634{ 635 return (S32)object->count(); 636} 637 638DefineEngineMethod( ArrayObject, countValue, S32, ( const char* value ),, 639 "Get the number of times a particular value is found in the array.\n" 640 "@param value Array element value to count\n" ) 641{ 642 return (S32)object->countValue( value ); 643} 644 645DefineEngineMethod( ArrayObject, countKey, S32, ( const char* key ),, 646 "Get the number of times a particular key is found in the array.\n" 647 "@param key Key value to count\n" ) 648{ 649 return (S32)object->countKey( key ); 650} 651 652DefineEngineMethod( ArrayObject, add, void, ( const char* key, const char* value ), ( "" ), 653 "Adds a new element to the end of an array (same as push_back()).\n" 654 "@param key Key for the new element\n" 655 "@param value Value for the new element\n" ) 656{ 657 object->push_back( key, value ); 658} 659 660DefineEngineMethod( ArrayObject, push_back, void, ( const char* key, const char* value ), ( "" ), 661 "Adds a new element to the end of an array.\n" 662 "@param key Key for the new element\n" 663 "@param value Value for the new element\n" ) 664{ 665 object->push_back( key, value ); 666} 667 668DefineEngineMethod( ArrayObject, push_front, void, ( const char* key, const char* value ), ( "" ), 669 "Adds a new element to the front of an array" ) 670{ 671 object->push_front( key, value ); 672} 673 674DefineEngineMethod( ArrayObject, insert, void, ( const char* key, const char* value, S32 index ),, 675 "Adds a new element to a specified position in the array.\n" 676 "- @a index = 0 will insert an element at the start of the array (same as push_front())\n" 677 "- @a index = %array.count() will insert an element at the end of the array (same as push_back())\n\n" 678 "@param key Key for the new element\n" 679 "@param value Value for the new element\n" 680 "@param index 0-based index at which to insert the new element" ) 681{ 682 object->insert( key, value, index ); 683} 684 685DefineEngineMethod( ArrayObject, pop_back, void, (),, 686 "Removes the last element from the array" ) 687{ 688 object->pop_back(); 689} 690 691DefineEngineMethod( ArrayObject, pop_front, void, (),, 692 "Removes the first element from the array" ) 693{ 694 object->pop_front(); 695} 696 697DefineEngineMethod( ArrayObject, erase, void, ( S32 index ),, 698 "Removes an element at a specific position from the array.\n" 699 "@param index 0-based index of the element to remove\n" ) 700{ 701 object->erase( index ); 702} 703 704DefineEngineMethod( ArrayObject, empty, void, (),, 705 "Emptys all elements from an array" ) 706{ 707 object->empty(); 708} 709 710DefineEngineMethod( ArrayObject, uniqueValue, void, (),, 711 "Removes any elements that have duplicated values (leaving the first instance)" ) 712{ 713 object->uniqueValue(); 714} 715 716DefineEngineMethod( ArrayObject, uniqueKey, void, (),, 717 "Removes any elements that have duplicated keys (leaving the first instance)" ) 718{ 719 object->uniqueKey(); 720} 721 722DefineEngineMethod( ArrayObject, duplicate, bool, ( ArrayObject* target ),, 723 "Alters array into an exact duplicate of the target array.\n" 724 "@param target ArrayObject to duplicate\n" ) 725{ 726 if ( target ) 727 { 728 object->duplicate( target ); 729 return true; 730 } 731 732 return false; 733} 734 735DefineEngineMethod( ArrayObject, crop, bool, ( ArrayObject* target ),, 736 "Removes elements with matching keys from array.\n" 737 "@param target ArrayObject containing keys to remove from this array\n" ) 738{ 739 if ( target ) 740 { 741 object->crop( target ); 742 return true; 743 } 744 745 return false; 746} 747 748DefineEngineMethod( ArrayObject, append, bool, ( ArrayObject* target ),, 749 "Appends the target array to the array object.\n" 750 "@param target ArrayObject to append to the end of this array\n" ) 751{ 752 if ( target ) 753 { 754 object->append( target ); 755 return true; 756 } 757 758 return false; 759} 760 761DefineEngineMethod( ArrayObject, sort, void, ( bool ascending ), ( false ), 762 "Alpha sorts the array by value\n\n" 763 "@param ascending [optional] True for ascending sort, false for descending sort\n" ) 764{ 765 object->sort( true, ascending, false ); 766} 767 768DefineEngineMethod( ArrayObject, sorta, void, (),, 769 "Alpha sorts the array by value in ascending order" ) 770{ 771 object->sort( true, true, false ); 772} 773 774DefineEngineMethod( ArrayObject, sortd, void, (),, 775 "Alpha sorts the array by value in descending order" ) 776{ 777 object->sort( true, false, false ); 778} 779 780DefineEngineMethod( ArrayObject, sortk, void, ( bool ascending ), ( false ), 781 "Alpha sorts the array by key\n\n" 782 "@param ascending [optional] True for ascending sort, false for descending sort\n" ) 783{ 784 object->sort( false, ascending, false ); 785} 786 787DefineEngineMethod( ArrayObject, sortka, void, (),, 788 "Alpha sorts the array by key in ascending order" ) 789{ 790 object->sort( false, true, false ); 791} 792 793DefineEngineMethod( ArrayObject, sortkd, void, (),, 794 "Alpha sorts the array by key in descending order" ) 795{ 796 object->sort( false, false, false ); 797} 798 799DefineEngineMethod( ArrayObject, sortn, void, ( bool ascending ), ( false ), 800 "Numerically sorts the array by value\n\n" 801 "@param ascending [optional] True for ascending sort, false for descending sort\n" ) 802{ 803 object->sort( true, ascending, true ); 804} 805 806DefineEngineMethod( ArrayObject, sortna, void, (),, 807 "Numerically sorts the array by value in ascending order" ) 808{ 809 object->sort( true, true, true ); 810} 811 812DefineEngineMethod( ArrayObject, sortnd, void, (),, 813 "Numerically sorts the array by value in descending order" ) 814{ 815 object->sort( true, false, true ); 816} 817 818DefineEngineMethod( ArrayObject, sortnk, void, ( bool ascending ), ( false ), 819 "Numerically sorts the array by key\n\n" 820 "@param ascending [optional] True for ascending sort, false for descending sort\n" ) 821{ 822 object->sort( false, ascending, true ); 823} 824 825DefineEngineMethod( ArrayObject, sortnka, void, (),, 826 "Numerical sorts the array by key in ascending order" ) 827{ 828 object->sort( false, true, true ); 829} 830 831DefineEngineMethod( ArrayObject, sortnkd, void, (),, 832 "Numerical sorts the array by key in descending order" ) 833{ 834 object->sort( false, false, true ); 835} 836 837DefineEngineMethod( ArrayObject, sortf, void, ( const char* functionName ),, 838 "Sorts the array by value in ascending order using the given callback function.\n" 839 "@param functionName Name of a function that takes two arguments A and B and returns -1 if A is less, 1 if B is less, and 0 if both are equal.\n\n" 840 "@tsexample\n" 841 "function mySortCallback(%a, %b)\n" 842 "{\n" 843 " return strcmp( %a.name, %b.name );\n" 844 "}\n\n" 845 "%array.sortf( \"mySortCallback\" );\n" 846 "@endtsexample\n" ) 847{ 848 object->sort( true, true, functionName ); 849} 850 851DefineEngineMethod( ArrayObject, sortfk, void, ( const char* functionName ),, 852 "Sorts the array by key in ascending order using the given callback function.\n" 853 "@param functionName Name of a function that takes two arguments A and B and returns -1 if A is less, 1 if B is less, and 0 if both are equal." 854 "@see sortf\n" ) 855{ 856 object->sort( false, true, functionName ); 857} 858 859DefineEngineMethod( ArrayObject, sortfd, void, ( const char* functionName ),, 860 "Sorts the array by value in descending order using the given callback function.\n" 861 "@param functionName Name of a function that takes two arguments A and B and returns -1 if A is less, 1 if B is less, and 0 if both are equal." 862 "@see sortf\n" ) 863{ 864 object->sort( true, false, functionName ); 865} 866 867DefineEngineMethod( ArrayObject, sortfkd, void, ( const char* functionName ),, 868 "Sorts the array by key in descending order using the given callback function.\n" 869 "@param functionName Name of a function that takes two arguments A and B and returns -1 if A is less, 1 if B is less, and 0 if both are equal." 870 "@see sortf\n" ) 871{ 872 object->sort( false, false, functionName ); 873} 874 875DefineEngineMethod( ArrayObject, moveFirst, S32, (),, 876 "Moves array pointer to start of array\n\n" 877 "@return Returns the new array pointer" ) 878{ 879 return object->moveFirst(); 880} 881 882DefineEngineMethod( ArrayObject, moveLast, S32, (),, 883 "Moves array pointer to end of array\n\n" 884 "@return Returns the new array pointer" ) 885{ 886 return object->moveLast(); 887} 888 889DefineEngineMethod( ArrayObject, moveNext, S32, (),, 890 "Moves array pointer to next position\n\n" 891 "@return Returns the new array pointer, or -1 if already at the end" ) 892{ 893 return object->moveNext(); 894} 895 896DefineEngineMethod( ArrayObject, movePrev, S32, (),, 897 "Moves array pointer to prev position\n\n" 898 "@return Returns the new array pointer, or -1 if already at the start" ) 899{ 900 return object->movePrev(); 901} 902 903DefineEngineMethod( ArrayObject, getCurrent, S32, (),, 904 "Gets the current pointer index" ) 905{ 906 return object->getCurrent(); 907} 908 909DefineEngineMethod( ArrayObject, setCurrent, void, ( S32 index ),, 910 "Sets the current pointer index.\n" 911 "@param index New 0-based pointer index\n" ) 912{ 913 object->setCurrent( index ); 914} 915 916DefineEngineMethod( ArrayObject, echo, void, (),, 917 "Echos the array contents to the console" ) 918{ 919 object->echo(); 920} 921