![]()
|
Top: Basic types: Lists: strlist: Manipulation #include <ptypes.h> int length(const strlist& s); void clear(strlist& s); void pack(strlist& s); void ins(strlist& s, int i, const string& str, unknown* obj); int add(strlist& s, const string& str, unknown* obj); void put(strlist& s, int i, const string& str, unknown* obj); void put(strlist& s, int i, unknown* obj); void del(strlist& s, int i); const string& getstr(const strlist& s, int i); unknown* get(const strlist& s, int i); int length(const strlist& s) returns the number of items in the given string list s. clear(strlist& s) clears all items of the list s. This function may also destroy all objects if the list "owns" the objects. pack(strlist& s) optimizes the memory usage for the strlist object. Useful when a big number of objects has been inserted and then deleted from the list. ins(strlist& s, int i, const string& istr, unknown* iobj) inserts string s and object obj at the position i. The position is 0-based. Inserting a new item at the position equal to the number of items is not an error -- in this case the function ins() does the same as function add(). This function can not be called for sorted string lists. int add(strlist& s, const string& str, unknown* obj) adds string s and object obj to the list s and returns the actual position at which the item was inserted. If the list is sorted, the new item is inserted at the proper position, otherwise it is appended to the end of the list. put(strlist& s, int i, string const& str, unknown* obj) assigns a new string/object pair values to the item i of the string list s. This operation is not allowed on sorted lists. The previous object may be destroyed depending on the flag SL_OWNOBJECTS. put(strlist& s, int i, unknown* obj) assigns a new object value to the item i of the string list s. The previous object may be destroyed depending on the flag SL_OWNOBJECTS. del(strlist& s, int i) removes the item at the position i from the string list s. The object associated with this item may be destroyed depending on the flag SL_OWNOBJECTS. const string& getstr(const strlist& s, int i) returns the string value of the item at the position i. See also Note below. unknown* get(const strlist& s, int i) returns the object value of the item at the position i. Indexed access to objects is also allowed through operator[]. See also Note below. Note: getstr(), get() and operator[] may generate an unrecoverable error if the index is out of bounds and if the library is compiled with either _DEBUG or DEBUG conditional symbol. In other words, the non-debugging version of the library never checks for index overlfows, thus making your program somewhat faster but less safe. See also: Constructors/destructors, Search PTypes home |