03.06.2016, 12:23
(
Последний раз редактировалось Ivan_Ino; 12.07.2016 в 18:22.
)
Hello everyone!
Yesterday I was doing something in java with an ArrayList, so I got the idea to do a ArrayList for PAWN...
This is a include which allows you to create arrays with changeable size trough functions.
Also, when you remove something all upper values in array will move on that place, so size of array will be -1.
Here is a list of functions with explain.
ArrayList:NewArrayList<TYPE>(capacity);
@ <TYPE> - Is type of ArrayList, it can be FLOAT or INTEGER
@ (capacity) - Changeable capacity on array
Example:
_______________________________________
ArrayList:: Destroy (ArrayList:ArrayListID);
@ ArrayList:ArrayListID - ID / Address of ArrayList which we want destroy
Example:
_______________________________________
ArrayList::IsValid(ArrayList:ArrayListID);
@ ArrayList:ArrayListID - ID / Address of ArrayList which we want check
Example:
_______________________________________
ArrayList::Add (ArrayList:ArrayListID, value);
@ ArrayList:ArrayListID - ID / Address of ArrayList
@ value - Value which we want add into list
Example:
_______________________________________
ArrayList::Remove(ArrayList:ArrayListID, index);
@ ArrayList:ArrayListID - ID / Address of ArrayList
@ index - Index in list
NOTE: When you remove example index 2, all upper indexes will move to -1
NOTE: For this is better use ArrayList::IndexOf function, explain down
Example:
_______________________________________
ArrayList::Size(ArrayList:ArrayListID);
@ ArrayList:ArrayListID - ID / Address of ArrayList
Example:
_______________________________________
ArrayList::Capacity(ArrayList:ArrayListID);
@ ArrayList:ArrayListID - ID / Address of ArrayList
Example:
_______________________________________
ArrayList::Get (ArrayList:ArrayListID, index);
@ ArrayList:ArrayListID - ID / Address of ArrayList
@ index - Return value from index
Example:
_______________________________________
ArrayList::EnsureCapacity (ArrayList:ArrayListID, newcapacity);
@ ArrayList:ArrayListID - ID / Address of ArrayList
@ newcapacity - New capacity value
Example:
_______________________________________
ArrayList::Clear(ArrayList:ArrayListID);
@ ArrayList:ArrayListID - ID / Address of ArrayList
Example:
_______________________________________
ArrayList::IndexOf (ArrayList:ArrayListID, value);
@ ArrayList:ArrayListID - ID / Address of ArrayList
@ value - Value from which we want get index
Example:
___________________________________________
Changes:
-
-
-
Bugs:
Wrong read values (FIXED*)
-
-
Download:
Version (1.0) available on GitHub on next link - https://github.com/Ino42O/PawnArrayList
An example script - https://github.com/Ino42O/PawnArrayL...istExample.pwn
SPEED TEST:
1000 items test:
10000 items test:
15000 items test:
Yesterday I was doing something in java with an ArrayList, so I got the idea to do a ArrayList for PAWN...
This is a include which allows you to create arrays with changeable size trough functions.
Also, when you remove something all upper values in array will move on that place, so size of array will be -1.
Here is a list of functions with explain.
ArrayList:NewArrayList<TYPE>(capacity);
@ <TYPE> - Is type of ArrayList, it can be FLOAT or INTEGER
@ (capacity) - Changeable capacity on array
Example:
PHP код:
new ArrayList:myList = NewArrayList<INTEGER>(5);
ArrayList:: Destroy (ArrayList:ArrayListID);
@ ArrayList:ArrayListID - ID / Address of ArrayList which we want destroy
Example:
PHP код:
new ArrayList:myList = NewArrayList<INTEGER>(5);
ArrayList::Destroy(myList);
ArrayList::IsValid(ArrayList:ArrayListID);
@ ArrayList:ArrayListID - ID / Address of ArrayList which we want check
Example:
PHP код:
if (ArrayList::IsValid(myList))
print ("List exist");
else
print ("List not exist");
ArrayList::Add (ArrayList:ArrayListID, value);
@ ArrayList:ArrayListID - ID / Address of ArrayList
@ value - Value which we want add into list
Example:
PHP код:
new ArrayList:myList = NewArrayList<INTEGER>(5);
ArrayList::Add (myList, 45641234);
new ArrayList:floatList = NewArrayList<FLOAT>(2);
ArrayList::Add (floatList, 55.0564495);
ArrayList::Remove(ArrayList:ArrayListID, index);
@ ArrayList:ArrayListID - ID / Address of ArrayList
@ index - Index in list
NOTE: When you remove example index 2, all upper indexes will move to -1
NOTE: For this is better use ArrayList::IndexOf function, explain down
Example:
PHP код:
new ArrayList:myList = NewArrayList<INTEGER>(5);
ArrayList::Add (myList, 45641234);
ArrayList::Add (myList, 123);
ArrayList::Add (myList, 687654);
ArrayList::Remove (myList, 1); //123
// this is better and safely
ArrayList::Remove (myList, ArrayList::IndexOf (myList, 123); // This will remove index where is value '123'
ArrayList::Size(ArrayList:ArrayListID);
@ ArrayList:ArrayListID - ID / Address of ArrayList
Example:
PHP код:
new ArrayList:myList = NewArrayList<INTEGER>(5);
ArrayList::Add (myList, 45641234);
ArrayList::Add (myList, 123);
ArrayList::Add (myList, 687654);
new size = ArrayList::Size (myList);
print (size); // This will print 3
ArrayList::Capacity(ArrayList:ArrayListID);
@ ArrayList:ArrayListID - ID / Address of ArrayList
Example:
PHP код:
new ArrayList:myList = NewArrayList<INTEGER>(5);
ArrayList::Add (myList, 45641234);
ArrayList::Add (myList, 123);
ArrayList::Add (myList, 687654);
new capacity = ArrayList::Capacity(myList);
print (capacity); // This will print 5
ArrayList::Get (ArrayList:ArrayListID, index);
@ ArrayList:ArrayListID - ID / Address of ArrayList
@ index - Return value from index
Example:
PHP код:
new ArrayList:myList = NewArrayList<INTEGER>(5);
ArrayList::Add (myList, 45641234);
ArrayList::Add (myList, 123);
ArrayList::Add (myList, 687654);
new index2 = ArrayList::Get (myList, 2);
print (index2); // This will print 687654
ArrayList::EnsureCapacity (ArrayList:ArrayListID, newcapacity);
@ ArrayList:ArrayListID - ID / Address of ArrayList
@ newcapacity - New capacity value
Example:
PHP код:
new ArrayList:myList = NewArrayList<INTEGER>(5); // Capacity now is 5
ArrayList::Add (myList, 45641234);
ArrayList::Add (myList, 123);
ArrayList::Add (myList, 687654);
ArrayList::EnsureCapacity (myList, 15); // Now capacity of myList is 15
ArrayList::Clear(ArrayList:ArrayListID);
@ ArrayList:ArrayListID - ID / Address of ArrayList
Example:
PHP код:
new ArrayList:myList = NewArrayList<INTEGER>(5); // Capacity now is 5
ArrayList::Add (myList, 45641234);
ArrayList::Add (myList, 123);
ArrayList::Add (myList, 687654);
// This will clear all values in this list
ArrayList::Clear(myList);
ArrayList::IndexOf (ArrayList:ArrayListID, value);
@ ArrayList:ArrayListID - ID / Address of ArrayList
@ value - Value from which we want get index
Example:
PHP код:
new ArrayList:myList = NewArrayList<INTEGER>(5);
ArrayList::Add (myList, 45641234); // index 0
ArrayList::Add (myList, 123); // index 1
ArrayList::Add (myList, 687654); //index 2 - we want this
new index = ArrayList::IndexOf (myList, 687654); // now index variable is 2
___________________________________________
Changes:
-
-
-
Bugs:
Wrong read values (FIXED*)
-
-
Download:
Version (1.0) available on GitHub on next link - https://github.com/Ino42O/PawnArrayList
An example script - https://github.com/Ino42O/PawnArrayL...istExample.pwn
SPEED TEST:
1000 items test:
Код:
[14:41:15] Test with 1000 items [14:41:15] Created and inserted items in 2ms, Readed in 2ms
Код:
[14:41:26] Test with 10000 items [14:41:26] Created and inserted items in 151ms, Readed in 149ms
Код:
[14:41:44] Test with 15000 items [14:41:44] Created and inserted items in 341ms, Readed in 335ms