insert( new : integer; var pq );
case pq is nil:
pq := NewSingleNode( new );
case pq is boolean array:
turn on corresponding entry;
case pq is single element:
expand entry to full node;
seep into next case;
case pq is full node:
compute index based on "new"
if bottom[index] <> nil then
insert in bottom[index]
else bottom[index] := NewSingleNode( new );
insert index in top queue;
adjust max and min if necessary;
end;
|