File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -70,15 +70,20 @@ class ArrayList {
70
70
return -1 ;
71
71
}
72
72
int lastIndexOf (E element) { return lastIndexOfInRange (element, 0 , _size); }
73
- ArrayList<E> copy () { return ArrayList<E>(this ); }
73
+ ArrayList<E> copy () { return ArrayList<E>(reinterpret_cast < size_t >( this ) ); }
74
74
ArrayList<E> operator +(const ArrayList<E> &other) { return add (other); }
75
75
ArrayList<E> &operator =(const ArrayList<E> &other) {
76
76
if (this != &other) {
77
77
ensureCapacityInternal (other._capacity );
78
- memcpy (_array, other._array , _size * sizeof (E));
78
+ if (other._size > 0 )
79
+ memcpy (_array, other._array , _size * sizeof (E));
79
80
}
80
81
return *this ;
81
82
}
83
+ E *begin () { return _array; }
84
+ E *end () { return _array + _size; }
85
+ const E *begin () const { return _array; }
86
+ const E *end () const { return _array + _size; }
82
87
};
83
88
84
89
You can’t perform that action at this time.
0 commit comments