82 #define min(a,b) (a<=b?a:b)
158 for (arrayPtr = this->
objects, endPtr = arrayPtr + this->
arraySize; arrayPtr < endPtr; arrayPtr++)
189 for (
size_t i = 0; i < this->
arraySize; i++)
243 this->
put(value, position);
257 for (
size_t i = 0; i < this->
size(); i++)
284 for (
size_t i = 0; i < this->
size(); i++)
327 put(value, newIndex);
361 position =
size() + 1;
367 position = position + 1;
428 memmove(_target, _start, _end - _start);
433 for (
size_t i =
index - 1; i <
index + elements - 1; i++)
461 for (
size_t i =
index; i <
index + elements; i++)
471 memmove(_target, _start, _end - _start);
490 put(value, newIndex);
518 _result = *(this->
data() + position - 1);
539 if (position > this->
size())
543 return get(position);
557 if (position > this->
size())
601 if (_index > 0 && _index <= this->
size() && *(this->
data() + _index - 1) !=
OREF_NULL)
604 result = *(this->
data() + _index - 1);
643 result = *(this->
data() + position - 1);
674 for (
size_t i = 0; i < realArray->
arraySize; i++)
739 if (this->
size() == 0)
791 size_t maxCount = this->
size();
797 size_t slotCount = this->
size();
798 size_t itemCount = this->
items();
808 for (
size_t i = 1; i <= slotCount; i++)
810 if (count >= maxCount)
break;
815 values->
put(item, count);
871 indexCount = indirect->
items();
872 _index = indirect->
data();
887 if (this->
size() != 0)
900 return this->
validateIndex(_index, indexCount, _start, bounds_error, position);
925 else if (indexCount == 0)
933 if (position > this->
size() )
960 numsubs = indexCount;
963 if (numsubs == numSize)
968 for (i = numsubs; i > 0; i--)
971 value = _index[i - 1];
982 if (position > _dimension)
991 return this->
validateIndex(_index, indexCount, _start, bounds_error, position);
1004 offset += multiplier * (position - 1);
1005 multiplier *= _dimension;
1007 position = offset + 1;
1010 else if (numsubs < numSize)
1016 #ifdef EXTEND_DIMENSIONS
1020 if (this->
size() != 0)
1029 this->extendMuti(_index, indexCount, _start);
1032 return this->
validateIndex(_index, indexCount, _start, bounds_error, position);
1056 if (newSize > this->
size())
1098 if (_end == 0 || _end > this->
size())
1100 _end = this->
size();
1104 newSize = _end + 1 - _start;
1146 nend = this->
size();
1159 if (nstart > this->
size())
1167 if (nend > this->
size() - nstart + 1)
1169 nend = this->
size() - nstart + 1;
1180 for (
size_t i = 1; i <= nend; i++)
1183 rref->
put(this->
get(nstart + i - 1), i);
1201 if (_start > this->
size())
1209 if (_end > this->
size() - _start + 1)
1212 _end = this->
size() - _start + 1;
1225 for (i = 1; i <= _end; i++)
1244 size_t _arraySize = this->
size();
1249 for (i = 0; i < _arraySize && thisObject[i] ==
OREF_NULL; i++);
1251 if (i == _arraySize)
1288 size_t _arraySize = this->
size();
1292 for (
size_t i = 0; i < _arraySize; i++)
1297 return thisObject[i];
1344 size_t _arraySize = this->
size();
1349 for (i = position; i < _arraySize && thisObject[i] ==
OREF_NULL; i++);
1351 if (i >= this->
size())
1372 size_t i = position;
1374 size_t _arraySize = this->
size();
1392 for (; i > 0 && thisObject[i-1] ==
OREF_NULL; i--);
1444 if (_index > 0 && _index <= this->
size() && *(this->
data() + _index - 1) !=
OREF_NULL)
1472 size_t maxCount = this->
size();
1486 for (
size_t iterator = 0; iterator < this->
size(); iterator++ )
1488 if (count >= maxCount)
break;
1492 newArray->
put(item[iterator], ++count);
1507 size_t maxCount = this->
size();
1522 for (
size_t iterator = 0; iterator < this->
size(); iterator++ )
1524 if (count >= maxCount)
break;
1548 return toString(format, separator);
1573 _items = newArray->
items();
1606 for (i = 1; i <=_items ; i++)
1608 item = newArray->
get(i);
1615 mutbuffer->
append(_stringValue);
1620 else if (i_form == 2)
1634 for (i = 1; i <= _items; i++)
1636 item = newArray->
get(i);
1648 mutbuffer->
append(_stringValue);
1670 memcpy(newArray->
data(), this->data(), this->dataSize());
1713 size_t _size = this->
size();
1714 size_t newSize = _size - amount;
1726 size_t _size = this->
size();
1727 for (
size_t i = 1; i <= _size; i++)
1729 if (this->
get(i) == target)
1754 size_t newSize = this->
size() + extension;
1755 size_t extendSize = this->
size() / 2;
1764 memcpy(newArray->
data(), this->data(), this->dataSize());
1788 for (
size_t i = 1; i <= this->
size(); i++)
1849 for (
size_t i = dims; i > 0; i--)
1856 size_t digit = idx % _dimension;
1860 idx = (idx - digit) / _dimension;
1937 size_t newDimension)
1947 size_t oldDimension;
1988 for (i= 1; i <= oldDimSize; i++)
1993 if (newDimSize > oldDimSize)
2002 skipAmount *= (newDimSize - oldDimSize);
2037 size_t additionalDim;
2039 size_t newDimension;
2040 size_t oldDimension;
2044 size_t newDimArraySize;
2046 size_t firstDimChanged = 0;
2058 newDimArraySize = _indexCount;
2059 newDimArray =
new_array(newDimArraySize);
2067 i = newDimArraySize - 1;
2071 if (newDimSize > this->
size())
2078 tempSize = this->
size();
2084 for (oldDimension = this->
dimensions->
size(), newDimension = newDimArraySize;
2086 oldDimension--, newDimension--)
2092 newDimSize = _index[newDimension - 1]->
requiredPositive(OREF_positional, (
int)newDimension);
2095 if (newDimSize > currDimSize)
2099 if (!firstDimChanged)
2102 firstDimChanged = newDimension;
2116 additionalDim = newDimArraySize - 1;
2125 if (additionalDim > 0)
2128 for (newDimension = additionalDim;
2133 newDimSize = ((
RexxInteger *)_index[newDimension - 1])->getValue();
2151 this->
size() == 0 ||
2152 !firstDimChanged || firstDimChanged <= additionalDim + 1)
2158 memcpy(newArray->
data(), this->data(),
sizeof(
RexxObject *) * this->size());
2168 for (i = newDimArraySize, accumSize = 1;
2169 i > firstDimChanged ;
2224 this->
put(value, _index);
2248 void * RexxArray::operator
new(
size_t size,
2262 for (;items > 0; items--)
2306 if ((
size_t)total_size >= MAX_FIXEDARRAY_SIZE)
2317 if (total_size == 0)
2345 size_t total_size = 1;
2346 for (
size_t i = 0; i < count; i++)
2362 total_size *= cur_size;
2396 size_t len = right - left + 1;
2399 for (
size_t i = left + 1; i <= right; i++) {
2402 if (comparator.
compare(current, prev) < 0) {
2406 }
while (j > left && comparator.
compare(current, prev =
get(j - 1)) < 0);
2413 size_t mid = (right + left) / 2;
2414 mergeSort(comparator, working, left, mid);
2415 mergeSort(comparator, working, mid + 1, right);
2416 merge(comparator, working, left, mid + 1, right);
2432 size_t leftEnd = mid - 1;
2440 size_t leftCursor = left;
2441 size_t rightCursor = mid;
2442 size_t workingPosition = left;
2452 if (comparator.
compare(fromVal, rightVal) <= 0)
2455 size_t leftInsertion =
find(comparator, rightVal, -1, leftCursor + 1, leftEnd);
2457 size_t toCopy = leftInsertion - leftCursor + 1;
2458 arraycopy(
this, leftCursor, working, workingPosition, toCopy);
2459 workingPosition += toCopy;
2461 working->
put(rightVal, workingPosition++);
2466 leftCursor = leftInsertion + 1;
2472 size_t rightInsertion =
find(comparator, fromVal, 0, rightCursor + 1, right);
2473 size_t toCopy = rightInsertion - rightCursor + 1;
2474 arraycopy(
this, rightCursor, working, workingPosition, toCopy);
2475 workingPosition += toCopy;
2477 working->
put(fromVal, workingPosition++);
2479 rightCursor = rightInsertion + 1;
2481 }
while (right >= rightCursor && mid > leftCursor);
2485 if (leftCursor < mid)
2487 arraycopy(
this, leftCursor, working, workingPosition, mid - leftCursor);
2491 arraycopy(
this, rightCursor, working, workingPosition, right - rightCursor + 1);
2495 arraycopy(working, left,
this, left, right - left + 1);
2510 for (
size_t i =
start; i <
start + count; i++)
2535 size_t checkPoint = left;
2537 while (checkPoint <= right)
2540 if (comparator.
compare(val,
get(checkPoint)) > limit)
2543 left = checkPoint + 1;
2548 right = checkPoint - 1;
2552 checkPoint += delta;
2558 while (left <= right)
2561 checkPoint = (left + right) / 2;
2562 if (comparator.
compare(val,
get(checkPoint)) > limit)
2565 left = checkPoint + 1;
2570 right = checkPoint - 1;
2587 size_t count =
items();
2595 for (
size_t i = 1; i <= count; i++)
2610 mergeSort(comparator, working, 1, count);
2625 size_t count =
items();
2633 for (
size_t i = 1; i <= count; i++)
2661 aref->
put(first, 1);
2671 aref->
put(first, 1);
2672 aref->
put(second, 2);
2676 void * RexxArray::operator
new(
size_t size,
2687 aref->
put(first, 1);
2688 aref->
put(second, 2);
2689 aref->
put(third, 3);
2694 void * RexxArray::operator
new(
size_t size,
2706 aref->
put(first, 1);
2707 aref->
put(second, 2);
2708 aref->
put(third, 3);
2709 aref->
put(fourth, 4);
2714 void * RexxArray::operator
new(
size_t size,
2727 aref->
put(first, 1);
2728 aref->
put(second, 2);
2729 aref->
put(third, 3);
2730 aref->
put(fourth, 4);
2731 aref->
put(fifth, 5);
2736 void *RexxArray::operator
new(
size_t newSize,
size_t size,
size_t maxSize,
RexxClass *arrayClass)
2741 arrayClass->checkAbstract();
2746 if (maxSize <= ARRAY_MIN_SIZE)
2748 maxSize = ARRAY_MIN_SIZE;
2756 bytes = newSize + (
sizeof(
RexxObject *) * (maxSize - 1));
2760 newArray->
setBehaviour(arrayClass->getInstanceBehaviour());
2768 if (arrayClass->hasUninitDefined())
2782 return new (arguments, (argCount + (2 * named_argCount)), (
RexxClass *)
this)
RexxArray;
2807 for (i = 0; i < argCount; i++)
2820 newArray =
new (argCount, args)
RexxArray;
void reportException(wholenumber_t error)
void missingArgument(RexxString *kind, size_t argumentPosition)
void copyElements(COPYELEMENTPARM *parm, size_t newDimension)
RexxArray * new_externalArray(size_t s, RexxClass *c)
RexxArray * new_array(size_t s)
#define RaiseBoundsTooMany
#define RaiseBoundsInvalid
RexxInteger * new_integer(wholenumber_t v)
RexxString * stringArgument(RexxObject *object, RexxString *kind, size_t position)
void requiredArgument(RexxObject *object, RexxString *kind, size_t position)
#define TheMutableBufferClass
#define Error_Incorrect_method_option
#define Error_Execution_sparse_array
#define Error_No_result_object_message
#define Error_Incorrect_method_array_too_big
#define Error_Incorrect_method_section
#define Error_Incorrect_method_minsub
#define Error_Incorrect_method_array_dimension
#define Error_Incorrect_method_maxarg
#define Error_Incorrect_method_array
#define Error_Incorrect_method_minarg
#define Error_Invalid_whole_number_compare
#define Error_Incorrect_method_noarg
#define Error_Incorrect_method_maxsub
#define memory_mark(oref)
RexxObject * new_object(size_t s)
#define flatten_reference(oref, envel)
#define CLASS_CREATE(name, id, className)
#define memory_mark_general(oref)
#define setUpFlatten(type)
RexxString * new_string(const char *s, stringsize_t l)
RexxSupplier * new_supplier(RexxArray *c, RexxArray *f)
virtual wholenumber_t compare(RexxObject *first, RexxObject *second)
static const wholenumber_t MAX_WHOLENUMBER
static wholenumber_t minVal(wholenumber_t n1, wholenumber_t n2)
static const size_t DEFAULT_DIGITS
RexxObject ** slotAddress(size_t index)
static const size_t ARRAY_DEFAULT_SIZE
static const size_t ARRAY_MIN_SIZE
RexxObject * getRexx(RexxObject **, size_t, size_t)
size_t findSingleIndexItem(RexxObject *item)
static const size_t MAX_FIXEDARRAY_SIZE
void flatten(RexxEnvelope *)
static void createInstance()
bool hasIndexNative(size_t)
void put(RexxObject *eref, size_t pos)
RexxObject * insertRexx(RexxObject *_value, RexxObject *index)
void closeGap(size_t index, size_t elements)
RexxObject * of(RexxObject **, size_t, size_t)
RexxObject * supplier(RexxObject *maxItems=OREF_NULL)
size_t find(BaseSortComparator &comparator, RexxObject *val, int bnd, size_t left, size_t right)
static RexxClass * classInstance
RexxObject * remove(size_t)
static void arraycopy(RexxArray *source, size_t start, RexxArray *target, size_t index, size_t count)
static RexxArray * nullArray
RexxObject * getApi(size_t pos)
size_t indexOf(RexxObject *)
RexxInteger * available(size_t position)
RexxObject * putRexx(RexxObject **, size_t, size_t)
RexxObject * join(RexxArray *)
RexxObject * newRexx(RexxObject **, size_t, size_t)
RexxArray * allItems(RexxObject *maxItems=OREF_NULL)
void openGap(size_t index, size_t elements)
bool isMultiDimensional()
RexxObject * nextRexx(RexxObject **, size_t, size_t)
RexxArray * allIndexes(RexxObject *maxIndexes=OREF_NULL)
RexxObject * deleteRexx(RexxObject *index)
RexxObject * convertIndex(size_t idx)
size_t append(RexxObject *)
RexxObject * appendRexx(RexxObject *)
void ensureSpace(size_t newSize)
RexxObject * index(RexxObject *)
void setExpansion(RexxObject *expansion)
size_t insert(RexxObject *_value, size_t index)
RexxArray * stableSortRexx()
RexxObject * sectionSubclass(size_t, size_t)
RexxObject * removeItem(RexxObject *)
bool isSingleDimensional()
RexxArray * section(size_t, size_t)
RexxObject * hasItem(RexxObject *)
void liveGeneral(int reason)
void putApi(RexxObject *eref, size_t pos)
RexxObject * deleteItem(size_t index)
RexxObject * removeRexx(RexxObject **, size_t, size_t)
RexxObject * fill(RexxObject *)
RexxObject * getDimensions()
RexxArray * stableSortWithRexx(RexxObject *comparator)
bool validateIndex(RexxObject **, size_t, size_t, size_t, stringsize_t &)
RexxObject * dimension(RexxObject *)
RexxArray * extend(size_t)
RexxObject * hasIndexRexx(RexxObject **, size_t, size_t)
RexxObject * sectionRexx(RexxObject *, RexxObject *)
RexxObject * previousRexx(RexxObject **, size_t, size_t)
RexxObject * get(size_t pos)
RexxArray * extendMulti(RexxObject **, size_t, size_t)
static RexxArray * createMultidimensional(RexxObject **dims, size_t count, RexxClass *)
RexxString * toString(RexxString *, RexxString *)
void mergeSort(BaseSortComparator &comparator, RexxArray *working, size_t left, size_t right)
RexxArray * expansionArray
void merge(BaseSortComparator &comparator, RexxArray *working, size_t left, size_t mid, size_t right)
RexxObject * indexToArray(size_t idx)
RexxClass * getOwningClass()
void setBehaviour(RexxBehaviour *b)
virtual RexxString * primitiveMakeString()
virtual RexxObject * getValue(RexxActivation *)
RexxBehaviour * behaviour
void reSize(RexxObject *, size_t)
RexxMutableBuffer * append(RexxObject *)
RexxString * makeString()
stringsize_t requiredPositive(RexxString *kind, size_t position, size_t precision=Numerics::ARGUMENT_DIGITS)
RexxMessage * start(RexxObject **, size_t, size_t)
virtual wholenumber_t compareTo(RexxObject *)
stringsize_t requiredNonNegative(RexxString *kind, size_t position, size_t precision=Numerics::ARGUMENT_DIGITS)
RexxString * makeString()
bool equalValue(RexxObject *other)
RexxString * requiredString(RexxString *kind, size_t)
void sendMessage(RexxString *, RexxArray *, RexxDirectory *, ProtectedObject &)
RexxObject * newRexx(RexxObject **arguments, size_t argCount, size_t named_argCount)
const char * getStringData()
virtual wholenumber_t compare(RexxObject *first, RexxObject *second)
size_t firstChangedDimension