Merge pull request #76 from xtutu/master

optimize array list
pull/87/head
Emir Pasic 6 years ago committed by GitHub
commit 6f0f602e3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -158,14 +158,8 @@ func (list *List) Insert(index int, values ...interface{}) {
l := len(values)
list.growBy(l)
list.size += l
// Shift old to right
for i := list.size - 1; i >= index+l; i-- {
list.elements[i] = list.elements[i-l]
}
// Insert new
for i, value := range values {
list.elements[index+i] = value
}
copy(list.elements[index+l:], list.elements[index:list.size - l])
copy(list.elements[index:], values)
}
// String returns a string representation of container

Loading…
Cancel
Save