void Vector_insert(T V, int i, void *e) { assert(V); assert(i >= 0 && i <= V->length); V->timestamp++; _ensureCapacity(V); for (int j = V->length++; j > i; j--) V->array[j] = V->array[j-1]; V->array[i] = e; }
void TextStream::writeLine(std::string const& str) { int len = str.size(); int offset = _position + 1; int newSize = offset + len + 1; _ensureCapacity(newSize); for (int i = 0; i < len; ++i) { _array[offset + i] = str[i]; } _array[offset + len] = (char)0x0A; _position += len + 1; _length = std::max(_length, newSize); }
void TextStream::write(std::string const& str) { int len = str.size(); int newSize = _position + 1 + len; int offset = _position + 1; _ensureCapacity(newSize); char const* ptr = str.c_str(); for (int i = 0; i < len; ++i) { _array[offset + i] = ptr[i]; } _position += len; _length = std::max(_length, newSize); }
void Vector_push(T V, void *e) { assert(V); V->timestamp++; _ensureCapacity(V); V->array[V->length++] = e; }