var a = [1,2,3]
a.push(10)
a.push(20)
assert a == [1,2,3,10,20]
redef fun push(item)
do
var node = tail_node
if not node.full then
if node.tail_index < node.capacity then
# There's room at the tail
node.tail_index += 1
else
# Move everything over by `d`
assert node.head_index > 0
var d = node.head_index / 2 + 1
node.move_head(node.length, d)
for i in d.times do node.items[node.tail_index - i] = null
node.head_index -= d
node.tail_index += -d+1
end
node.items[node.tail_index-1] = item
else
# New node!
node = new UnrolledNode[E](nodes_length)
insert_node(node, tail_node, null)
node.tail_index = 1
node.items[0] = item
end
length += 1
end
lib/more_collections/more_collections.nit:427,2--452,4
# Adding the signal to release eventual waiting thread(s)
redef fun push(e) do
mutex.lock
if real_collection.is_empty and not actor.working then
actor.working = true
sys.active_actors.increment
real_collection.push(e)
self.cond.signal
else
real_collection.push(e)
end
mutex.unlock
end
lib/actors/actors.nit:78,2--90,4