var a = [1,2,3]
a.unshift(10)
a.unshift(20)
assert a == [20,10,1,2,3]
redef fun unshift(item)
do
var node = head_node
if not node.full then
if node.head_index > 0 then
# There's room at the head
node.head_index -= 1
else
# Move everything over by `d`
assert node.tail_index < node.capacity
var d = (node.capacity-node.tail_index) / 2 + 1
node.move_tail(0, d)
for i in d.times do node.items[node.head_index+i] = null
node.head_index += d-1
node.tail_index += d
end
node.items[node.head_index] = item
else
# New node!
node = new UnrolledNode[E](nodes_length)
insert_node(node, null, head_node)
node.head_index = node.capacity-1
node.tail_index = node.capacity
node.items[node.capacity-1] = item
end
length += 1
end
lib/more_collections/more_collections.nit:454,2--480,4