Skip to content

Commit ebdf9e4

Browse files
committed
Adding dequeue
1 parent 2f089cc commit ebdf9e4

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
items=()
4+
while true ; do
5+
echo "... "
6+
read -r line
7+
args=($line)
8+
case ${args[0]} in
9+
"FADD")
10+
arg_list=(${args[1]})
11+
arg_list+=${items[@]}
12+
items=$arg_list
13+
;;
14+
"RADD")
15+
items+=(${args[1]})
16+
;;
17+
"FPOP")
18+
echo "${items[0]}"
19+
items=${items[@]:1}
20+
;;
21+
"RPOP")
22+
echo "${items[-1]}"
23+
items=${items[@]:0:$((${#items[@]} - 1))}
24+
;;
25+
esac
26+
27+
done

0 commit comments

Comments
 (0)