comparison tests/farray-alist.t @ 745:a5918c859fe9

farray.sh: Implement falist_find() -- a variant of falist_contains() that also returns the found index proper
author Franz Glasner <fzglas.hg@dom66.de>
date Tue, 08 Oct 2024 17:55:23 +0200
parents 6fcf7da87981
children 7e2279d6db0f
comparison
equal deleted inserted replaced
744:93ff221b9c35 745:a5918c859fe9
72 ERROR: object `LIST' not created properly: token empty 72 ERROR: object `LIST' not created properly: token empty
73 [1] 73 [1]
74 $ check_no_alist_artifacts 74 $ check_no_alist_artifacts
75 75
76 76
77 Get / Set / Contains 77 Get / Set / Contains / Find Index
78 ==================== 78 =================================
79 79
80 $ falist_create LIST 80 $ falist_create LIST
81 $ falist_set LIST K1 V1 81 $ falist_set LIST K1 V1
82 $ falist_set LIST K2 V2 82 $ falist_set LIST K2 V2
83 $ falist_debug LIST 83 $ falist_debug LIST
106 3 106 3
107 $ falist_print_length LIST 107 $ falist_print_length LIST
108 3 (no-eol) 108 3 (no-eol)
109 109
110 $ falist_contains LIST K1 110 $ falist_contains LIST K1
111 $ falist_find idx LIST K1
112 $ test "$idx" -eq 1
111 $ falist_contains LIST K 113 $ falist_contains LIST K
114 [1]
115 $ falist_find idx LIST K
112 [1] 116 [1]
113 $ falist_get _var LIST K2 117 $ falist_get _var LIST K2
114 $ echo "$_var" 118 $ echo "$_var"
115 V2 2 119 V2 2
116 $ falist_tryget _var LIST K1 120 $ falist_tryget _var LIST K1