示例#1
0
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;
}
示例#2
0
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);
}
示例#3
0
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);
}
示例#4
0
void Vector_push(T V, void *e) {
        assert(V);
	V->timestamp++;
        _ensureCapacity(V);
        V->array[V->length++] = e;
}