![]() |
ARSA Language
2.9
(Recursion, Encryption, GPU and Web 3.0)
|
#include <array.h>
Public Member Functions | |
| int | array () |
| allocate new memory of array More... | |
| bool | array (const char *name) |
| allocate new memory of array with an alias name. this name using instread an id. More... | |
| int | allocate (int start_count) |
| Constructs an array and allocates an initial chunk of memory. More... | |
| int | allocate (const char *name, int start_count) |
| Constructs an array and allocates an initial chunk of memory with an alias name. this name using instread an id. More... | |
| int | push_back (int id, const T &element) |
| int | push_front (int id, const T &element) |
| void | reallocate (int id, int new_size) |
| Reallocates the array, make it bigger or smaller. More... | |
| void | set_used (int id, int usedNow) |
| Sets the size of the array and allocates new elements if necessary. More... | |
| const T & | get (int id, int index) |
| Direct const access operator. More... | |
| int | size (int id) |
| Get number of occupied elements of the array. More... | |
| int | allocatedsize (int id) |
| Get amount of memory allocated. More... | |
| int | erase (int id, int index) |
| void | clear (int id) |
| Clears the array and deletes all allocated memory. More... | |
| bool | close (int id) |
| free memory of array More... | |
| int | insert (int id, const T &element, int index) |
| int | search (int id, const T &element) |
| int | search_array (int id, const T &element) |
| bool | sort (int id) |
| void | for (int id, void *function) |
| get element from array with for loop. More... | |
| bool | set (int id, int index, const T &new_element) |
| update element in specific slot. More... | |
| void | log (int id) |
| print all elements in log window More... | |
| bool | save (int id, const char *filename, const char *option="xml") |
| save all elements to file as xml or json More... | |
| const char * | tostring (int id, const char *option="xml") |
| save all elements and value to string buffer as xml or json More... | |
| int array::array | ( | ) |
allocate new memory of array
| bool array::array | ( | const char * | name | ) |
allocate new memory of array with an alias name. this name using instread an id.
| name | array alias name, should be a uniqueness name. |
Constructs an array and allocates an initial chunk of memory.
| start_count | Amount of elements to pre-allocate. default is 6. |
Constructs an array and allocates an initial chunk of memory with an alias name. this name using instread an id.
| name | array alias name, should be a uniqueness name. |
| start_count | Amount of elements to pre-allocate. default is 6. |
Get amount of memory allocated.
| id | array id. |
| void array::clear | ( | int | id | ) |
Clears the array and deletes all allocated memory.
| id | array id. |
| bool array::close | ( | int | id | ) |
free memory of array
| id | array id. |
Erases an element from the array.
May be slow, because all elements following after the erased element have to be copied.
| id | array id. |
| index | Index of element to be operate. |
| void array::for | ( | int | id, |
| void * | function | ||
| ) |
get element from array with for loop.
| id | array id. |
| function | call the function until end loop. Automatic built-in index loop each, can using "null" with function: array.get() array.set() Using break() or return() to stop them. |
Direct const access operator.
| id | array id. |
| index | Index of element to be operate. |
Insert item into array at specified position.
Please use this only if you know what you are doing(possible performance loss).The preferred method of adding elements should be array.push_back().
| id | array id. |
| element | Element to be inserted. |
| index | Where position to insert the new element. |
| void array::log | ( | int | id | ) |
print all elements in log window
| id | array id. |
Adds an element at back of array.
If the array is too small to add this new element it is made bigger.
| id | array id. |
| element | Element to add at the back of the array. |
Adds an element at the front of the array.
If the array is to small to add this new element, the array is made bigger.Please note that this is slow, because the whole array needs to be copied for this.
| id | array id. |
| element | Element to add at the front of the array. |
Reallocates the array, make it bigger or smaller.
| id | array id. |
| new_size | New size of array. |
| bool array::save | ( | int | id, |
| const char * | filename, | ||
| const char * | option = "xml" |
||
| ) |
save all elements to file as xml or json
| id | array id. |
| option | file type xml or json. default: xml |
Finds an element in linear time, which is very slow.
Only works if == operator is implemented.
| id | array id. |
| element | Element to search for. |
Finds an element in linear time, which is very slow.
also return new array include a set of data founded if.
| id | array id. |
| element | Element to search for. |
update element in specific slot.
| id | array id. |
| index | Where position to insert the new element. |
| new_element | Element to update. |
Sets the size of the array and allocates new elements if necessary.
| id | array id. |
| usedNow | Amount of elements now used. |
Get number of occupied elements of the array.
| id | array id. |
| bool array::sort | ( | int | id | ) |
Sorts the array using heapsort.
There is no additional memory waste and the algorithm performs O(n*log n) in worst case.
| id | array id. |
| const char* array::tostring | ( | int | id, |
| const char * | option = "xml" |
||
| ) |
save all elements and value to string buffer as xml or json
| id | array id. |
| option | file type xml or json. default: xml |