For people who want to port code from shvector to adt_array, here's how the commands map to adt_array:
PHP Code:
// Handle:vector = SHVectorCreate(TYPE_CELL);
new Handle:array = CreateArray();
// Handle:vector = SHVectorCreate(TYPE_STRING);
new Handle:array = CreateArray(ByteCountToCells(64)); // for 64 character strings
// SHVectorFree_Cell(vector);
// SHVectorFree_String(vector);
CloseHandle(array);
// new value = SHVectorAt_Cell(vector, pos);
new value = GetArrayCell(array, pos);
// new Handle:value = SHVectorAt_Cell(vector, pos);
new Handle:value = Handle:GetArrayCell(array, pos);
// GetArrayFloat also exists
decl String:myString[64];
// SHVectorAt_String(vector, pos, myString, sizeof(myString));
GetArrayString(array, pos, myString, sizeof(myString));
// SHVectorSetAt_Cell(vector, pos, value);
SetArrayCell(array, pos, value)
PushArrayCell(array, value); // To add new items to the end of the array
//SetArrayFloat and PushArrayFloat also exist
// SHVectorSetAt_String(vector, pos, value);
SetArrayString(array, pos, value);
PushArrayString(array, value); // To add new items to the end of the array
// SHVectorClear_Cell(vector);
// SHVectorClear_String(vector)
ClearArray(array);
// if (SHVectorIsEmpty_Cell(vector))
// if (SHVectorIsEmpty_String(vector))
if (GetArraySize(array) == 0)
// SHVectorSwap_Cell(vector, pos1, pos2)
// SHVectorSwap_String(vector, pos1, pos2)
SwapArrayItems(array, pos1, pos2)
// SHVectorInsert_Cell(vector, where, value);
InsertArrayCell(array, where, value)
// InsertArrayFloat also exists
// SHVectorInsert_String(vector, where, value);
InsertArrayString(array, where, value);
// SHVectorErase_Cell(vector, pos);
// SHVectorErase_String(vector, pos)
RemoveFromArray(array, pos);
// SHVectorSize_Cell(vector)
// SHVectorSize_String(vector)
GetArraySize(vector)
Keep in mind that you
can't SetArrayCell or SetArrayString to cells that don't exist... you can ResizeArray(array, 30) to resize the array to have 30 elements (for example) which will create new, empty values in the array is smaller than 30 (or get rid of elements past pos 29 if larger than 30). You can also ShiftArrayUp(array, pos) to create a new empty value in the middle of an array at position pos
__________________