Like a List, a NamedList has an array of items which can be accessed by index. Like a dictionary, its items can also be accessed by names. Items can be added and removed and replaced by name. It also supports pseudo-object style like a dict.
Not used yet in Modality.
NamedList also does quite efficient lookup: put, at
methods are reasonably fast, and direct lookup with NamedList.dict[key]
or NamedList.array[index]
is almost as fast as with Array and Event.
add, remove, removeAt
methods are slower than with arrays or dicts, due to the overhead of keeping array, names and dict in sync. This design assumes that lookup will happen several orders of magnitude more often than add/remove.
create new NamedList from array of pairs
n = NamedList([ \a, 4, \b, 5, \c, 6 ]);
create new NamedList from dict and optional ordered names or sortFunc.
create new NamedList from array of values and names
create new NamedList from array of associations:
the ordered list of names
n.names.postcs;
the unordered dict of items - for fast access by key
n.dict.postcs;
flag whether to use pseudomethods or not
put by key (name), index or collection of keys/indices
put by key (name) or index
add by name; if name exists, replaces item at name, else adds item to end n.add(\aaa, \xyz);
remove item from dict, array, and remove corresponding name. n.remove(\xyz);
remove item at key, index or list of keys and indices.
add relative to another named item
add to top or end of list
replace item at <name> with <item>.
like List.do, collect