Skip to content

Commit 3a824bf

Browse files
committed
Classical data structures
1 parent 232dff3 commit 3a824bf

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

Classical/queue/shell/main.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
Q=()
4+
PROMPT='-> '
5+
while [[ true ]]; do
6+
echo "$PROMPT"
7+
read line
8+
ARG=($line)
9+
10+
case ${ARG[0]} in
11+
"ADD") Q+=(${ARG[1]}) && echo "Added"
12+
;;
13+
"POP") echo ${Q[0]} && Q=${Q[@]:1}
14+
;;
15+
esac
16+
17+
done

Classical/stack/shell/main.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
S=()
4+
PMP="->"
5+
while [[ true ]]; do
6+
echo $PMP
7+
read line
8+
ARG=($line)
9+
case ${ARG[0]} in
10+
"ADD") Q+=(${ARG[1]}) && echo "Added"
11+
;;
12+
"POP") echo "${Q[@]:(-1)}" && Q=(${Q[@]:0:${#Q[@]-2}})
13+
;;
14+
esac
15+
done

0 commit comments

Comments
 (0)