#bash has no queue: an array, where enqueue adds to the end
#and dequeue takes from the start
intQueue=()
intQueue+=(1)
intQueue+=(3)
intQueue+=(5)
top=${intQueue[0]}
#top is 1
#dequeue: read the first element, then keep the rest;
#the slice numbers the elements from 0 again
first=${intQueue[0]}
intQueue=("${intQueue[@]:1}")
#first is 1
second=${intQueue[0]}
intQueue=("${intQueue[@]:1}")
#second is 3
intQueue+=(7 9)
third=${intQueue[0]}
intQueue=("${intQueue[@]:1}")
#third is 5
#the slice copies the whole rest each time:
#good for a short queue, slow for thousands of elements
count=${#intQueue[@]}
#count is 2, intQueue is (7 9)
echo "top is $top"
echo "first is $first"
echo "second is $second"
echo "third is $third"
echo "count is $count"
echo "intQueue is (${intQueue[*]})"