--- /dev/null
+
+
+# when the array elements have spaces, it is still possible to get them back right.
+
+
+a=("ted row" "boon" "moopy dongle")
+echo ${#a[@]}
+# 3
+borg=( "${a[@]}" )
+echo ${#borg[@]}
+# 3
+
+# normally the setting of borg would not preserve the elements with spaces in them as separate.
+# but by using the @ to get all the array members and the spaces around the reference, you get
+# the list back properly.
+
--- /dev/null
+#!/bin/bash
+#
+# tests the array sifter methods.
+
+source $FEISTY_MEOW_SCRIPTS/core/array_sifter.sh
+
+#demo 1 & 2 for test presence.
+declare -a my_array=(peanuts sauce fish basil)
+
+test1=basil
+test_presence my_array $test1
+if [ $? != 0 ]; then
+ echo "test1 did not find flag, but should have."
+else
+ echo "test1 found expected flag."
+fi
+
+test2=spoo
+test_presence my_array $test2
+if [ $? != 0 ]; then
+ echo "test2 did not find flag, which is correct."
+else
+ echo "test2 found flag when should not have."
+fi
+
+#############################################
+
+#demo3 for sifting...
+
+declare -a sift_list=(ontrack selenium aggressive)
+declare -a stripping=(selenium)
+declare -a store_list=()
+
+sift_array "sift_list" "stripping" "store_list"
+if [ ${store_list[0]} == "selenium" ]; then
+ echo "test3 found expected content in storage list."
+else
+ echo "test3 was missing expected content in storage list."
+fi
+echo sift is now ${sift_list[*]}
+if [ "${sift_list[*]}" == "ontrack aggressive" ]; then
+ echo "test3 found expected content in sifting list."
+else
+ echo "test3 was missing expected content in sifting list."
+fi
+
+
--- /dev/null
+#!/bin/bash
+
+##############
+
+# simple examples...
+
+declare -A snuggles
+ # make an associative array
+
+snuggles=([book]=petunia "[muffets]=glasgow robbery")
+ # keys: book and muffets
+ # values: (second part)
+
+snuggles+=([morgower]=flimshaw)
+ # adding entries to it.
+
+echo ${!snuggles[x]}
+ # show index x's key.
+
+echo ${snuggles[x]}
+ # show index x's value.
+
+##############
+
+# excellent code from:
+# http://blog.spencertipping.com/2009/08/constant-time-associative-arrays-in-bash
+
+typeset -a table_keys
+typeset -a table_values
+
+function index_of_key () {
+ initial=$(($(echo $1 | md5sum | cut -c 18-32 | awk '{print "0x"$1}')))
+ while [[ ${table_keys[$initial]} && ${table_keys[$initial]} != $1 ]]; do
+ initial=$((initial + 1))
+ done
+ echo -n $initial
+}
+
+function associate () {
+ index=$(index_of_key $1)
+ table_keys[$index]=$1
+ table_values[$index]=$2
+ echo -n $2
+}
+
+function lookup () {
+ index=$(index_of_key $1)
+ echo -n ${table_values[$index]}
+}
+
+echo Associating foo with bar and bif with baz
+associate foo bar && echo
+associate bif baz && echo
+
+echo -n Looking up foo:
+lookup foo && echo
+
+echo -n Looking up bif:
+lookup bif && echo
+
+echo -n Looking up bar:
+lookup bar && echo
+
+##############
+