Sync AMTL.

This commit is contained in:
David Anderson
2013-08-29 11:45:28 -07:00
parent 1c40d77b14
commit da9debda67
5 changed files with 128 additions and 62 deletions
+23 -11
View File
@@ -43,24 +43,23 @@ class Vector : public AllocPolicy
{
public:
Vector(AllocPolicy = AllocPolicy())
: data_(NULL),
nitems_(0),
maxsize_(0)
: data_(NULL),
nitems_(0),
maxsize_(0)
{
}
Vector(Moveable<Vector<T, AllocPolicy> > other) {
data_ = other->data_;
nitems_ = other->nitems_;
maxsize_ = other->maxsize_;
other->reset();
}
~Vector() {
zap();
}
void steal(Vector &other) {
zap();
data_ = other.data_;
nitems_ = other.nitems_;
maxsize_ = other.maxsize_;
other.reset();
}
bool append(const T &item) {
if (!growIfNeeded(1))
return false;
@@ -68,11 +67,24 @@ class Vector : public AllocPolicy
nitems_++;
return true;
}
bool append(Moveable<T> item) {
if (!growIfNeeded(1))
return false;
new (&data_[nitems_]) T(item);
nitems_++;
return true;
}
void infallibleAppend(const T &item) {
assert(growIfNeeded(1));
new (&data_[nitems_]) T(item);
nitems_++;
}
void infallibleAppend(Moveable<T> item) {
assert(growIfNeeded(1));
new (&data_[nitems_]) T(item);
nitems_++;
}
T popCopy() {
T t = at(length() - 1);
pop();