|
@@ -188,6 +188,12 @@ namespace Core {
|
|
|
return Core::toString(s, *this);
|
|
|
}
|
|
|
|
|
|
+ void swap(List& other) {
|
|
|
+ Core::swap(length, other.length);
|
|
|
+ Core::swap(capacity, other.capacity);
|
|
|
+ Core::swap(data, other.data);
|
|
|
+ }
|
|
|
+
|
|
|
private:
|
|
|
static Error allocate(T*& t, int n) {
|
|
|
if(n <= 0) {
|
|
@@ -198,12 +204,6 @@ namespace Core {
|
|
|
return t == nullptr ? Error::OUT_OF_MEMORY : Error::NONE;
|
|
|
}
|
|
|
|
|
|
- void swap(List& other) {
|
|
|
- Core::swap(length, other.length);
|
|
|
- Core::swap(capacity, other.capacity);
|
|
|
- Core::swap(data, other.data);
|
|
|
- }
|
|
|
-
|
|
|
check_return Error ensureCapacity() {
|
|
|
return length >= capacity
|
|
|
? reserve(capacity + Core::Math::max(4, capacity / 4))
|