<< Click to Display Table of Contents >> Navigation: Reference Manual > Arrays and matrices > DSL_stringArray |
Header file: stringarray.h
DSL_stringArray();
DSL_stringArray(int arraySize);
DSL_stringArray(const DSL_stringArray& other)
DSL_stringArray(std::initializer_list<const char*> initList)
~DSL_stringArray();
DSL_stringArray& operator=(const DSL_stringArray& other);
The default constructor, copy constructors, operator= and destructor are implemented. The methods accepting std::initializer_list as input are available only if C++11 standard is enabled during compliation. The constructor accepting an integer array size initializes all elements to be empty strings.
const char* const* begin() const;
const char* const* end() const;
The methods to enable C++ 11 range-based for loops. Can also be used with any Standard Library algorithm accepting const random access iterators.
const char* operator[](int index) const;
const char* Subscript(int index) const;
Indexed read access. The debug build of the library checks the index and asserts if the index is invalid.
virtual int SetString(int index, const char *value) const;
Indexed write access. Returns DSL_OKAY, or a DSL_OUT_OF_RANGE (a negative number) when index is invalid.
int FindPosition(const char* value) const;
Uses strcmp to find the index of the specified value. If the value is not found, returns DSL_OUT_OF_RANGE (a negative number).
bool Contains(const char* value) const;
Returns true if the specified value is present in the network.
bool IsEmpty() const
Returns true if the array is empty.
int GetSize() const;
Returns the number of elements in the array.
int Reserve(int newReserved);
Reserves the buffer capacity, use in performance-critical scenarios. Does not change the size of the array returned from GetSize.
void Clear();
Sets the array size to zero.
virtual int Add(const char *value);
Adds new element at the end of the array.
virtual int Insert(int index, const char *value);
Inserts new element in the array at the specified index. Returns DSL_OKAY, or DSL_OUT_OF_RANGE if the index is negative or greater than array size. Insert can be called with index equal to the array size. In such case, Add is invoked.
int Delete(int index);
Removes the element in the array at the specified index. The elements after the removed element are shifted toward the beginning of the array. Returns DSL_OKAY, or DSL_OUT_OF_RANGE if the index is negative or greater than array size.
int DeleteByContent(const char *value);
Uses FindPosition to find the index of specified value, and if found, removes the value with a call to Delete. If the value is not present in the network, returns DSL_OUT_OF_RANGE.
int ChangeOrder(const DSL_intArray& permutation);
Changes the order of elements in the array using the specified permutation. Returns DSL_OKAY on success, or a negative error code if the specified permutation array is not actually a permutation. The permutation array indices are used as sources. For example, {"a","b","c","d"} will become {"d","a","b","c"} when ChangeOrder is called with the permutation {3,0,1,2}.
int NumItems() const;
BACKWARD COMPATIBILITY ONLY. Available when SMILE_NO_V1_COMPATIBILITY is not defined.