2
* <p>Class MVList provides a simple multi value list,
3
* instead of a mapping there is no limitation on one single index value pair</p>
10
private mapping(string:array(string)) list = ([]);
15
* <p>adds a index value pair. If the index exists, the value will be appendended</p>
18
* @param index - the index for the multivalues
19
* @param value - the value for the index, either string or an array,
21
public void add(string index, string|array(string) value)
25
if(has_index(list,index))
27
array valuelist = list[index];
30
else if(stringp(value))
31
valuelist+=({ value });
33
list[index]=valuelist;
38
list+=([ index : value ]);
39
else if(stringp(value))
40
list+=([ index : ({ value }) ]);
46
* <p>remove a value from the list</p>
49
* @param index - the index of the value to remove
50
* @param value - the value to remove
53
public int remove(string index, string value)
55
if(has_index(list,index))
57
array valuelist = list[index];
58
if(has_value(valuelist,value))
60
valuelist-=({ value });
61
list[index]=valuelist;
74
* <p>replaces a index</p>
77
* @param string index_old - the index to replace
78
* @param string index_new - the new index
81
public int replace(string index_old, string index_new)
83
if(has_index(list,index_old))
85
array valuelist = list[index_old];
86
m_delete(list, index_old);
87
add(index_new,valuelist);
95
* <p>checks if a index - value pair exists in the list</p>
98
* @param index - the index
99
* @param value - the value
102
public int has_index_value(string index, string value)
104
if(has_index(list,index))
106
array valuelist = list[index];
107
if(has_value(valuelist,value))
119
* <p>removes an index and all connected values from the list</p>
122
* @param index - the index to remove
125
public int remove_index(string index)
127
if(has_index(list,index))
129
return m_delete(list, index);;
134
* <p>get all values of a given index</p>
137
* @param index - the index of the values
138
* @return values as array
140
public array get(string index)
142
if(has_index(list,index))
152
* <p>checks if a index exists in the list</p>
155
* @param index - the index to check
158
public int provides_index(string index)
160
return has_index(list,index);
165
* <p>returns the list in the form of mapping(string:array(string))</p>
168
* @return - the list as mapping
170
public mapping get_list()
177
* <p>get all indexes of the list</p>
180
* @return array with all identifiers (indexes)
182
public array get_indexes()
184
return indices(list);