PIP 5.9.0
Platform-Independent Primitives
Loading...
Searching...
No Matches
PIStringList Class Reference

Based on PIDeque<PIString> strings list. More...

#include <pistringlist.h>

Inheritance diagram for PIStringList:

Public Member Functions

 PIStringList ()
 Contructs an empty strings list.
 PIStringList (const PIString &str)
 Contructs strings list with one string "str".
 PIStringList (const PIString &s0, const PIString &s1)
 Contructs strings list with strings "s0" and "s1".
 PIStringList (const PIString &s0, const PIString &s1, const PIString &s2)
 Contructs strings list with strings "s0", "s1" and "s2".
 PIStringList (const PIString &s0, const PIString &s1, const PIString &s2, const PIString &s3)
 Contructs strings list with strings "s0", "s1", "s2" and "s3".
 PIStringList (const PIStringList &o)
 Contructs strings list with strings "o".
 PIStringList (const PIVector< PIString > &o)
 Contructs strings list with strings "o".
 PIStringList (const PIDeque< PIString > &o)
 Contructs strings list with strings "o".
 PIStringList (std::initializer_list< PIString > init_list)
 Contructs strings list with strings "init_list" in std::initializer_list format.
PIString join (const PIString &delim) const
 Join all strings in one with delimiter "delim" and returns it.
PIStringList & removeStrings (const PIString &value)
 Remove all strings equal "value" and returns reference to this.
PIStringList & removeDuplicates ()
 Remove duplicated strings and returns reference to this.
PIStringList & trim ()
 Trim all strings and returns reference to this.
uint contentSize ()
 Returns sum of lengths of all strings.
bool operator== (const PIStringList &o) const
 Compare operator.
bool operator!= (const PIStringList &o) const
 Compare operator.
PIStringList & operator= (const PIStringList &o)
 Assign operator.
PIStringList & operator<< (const PIString &str)
 Append string "str".
PIStringList & operator<< (const PIStringList &sl)
 Append strings list "sl".
Public Member Functions inherited from PIDeque< PIString >
 PIDeque ()
 Constructs an empty array.
PIDeque< PIString > & operator= (const PIDeque< PIString > &other)
 Assign operator.
iterator begin ()
 Iterator to the first element.
iterator end ()
 Iterator to the element following the last element.
reverse_iterator rbegin ()
 Returns a reverse iterator to the first element of the reversed array.
reverse_iterator rend ()
 Returns a reverse iterator to the element. following the last element of the reversed array.
size_t size () const
 Number of elements in the container.
ssize_t size_s () const
 Number of elements in the container as signed value.
size_t length () const
 Same as size().
size_t capacity () const
 Number of elements that the container has currently allocated space for.
bool isEmpty () const
 Checks if the container has no elements.
bool isNotEmpty () const
 Checks if the container has elements.
bool any (std::function< bool(const PIString &e)> test) const
 Tests whether at least one element in the array passes the test implemented by the provided function test.
bool every (std::function< bool(const PIString &e)> test) const
 Tests whether all elements in the array passes the test implemented by the provided function test.
PIString & operator[] (size_t index)
 Full access to element by index.
const PIString & at (size_t index) const
 Read only access to element by index.
const PIString & atWhere (std::function< bool(const PIString &e)> test, ssize_t start=0, const PIString &def=PIString()) const
 Returns the first element of the array that passes the test implemented by the provided function test or def if there is no such element.
const PIString & lastAtWhere (std::function< bool(const PIString &e)> test, ssize_t start=-1, const PIString &def=PIString()) const
 Returns the last element of the array that passes the test implemented by the provided function test or def if there is no such element.
PIString & back ()
 Last element.
PIString & front ()
 Last element.
bool operator== (const PIDeque< PIString > &v) const
 Compare operator with array v.
bool operator!= (const PIDeque< PIString > &v) const
 Compare operator with array v.
bool contains (const PIString &e, ssize_t start=0) const
 Tests if element e exists in the array.
int entries (const PIString &e, ssize_t start=0) const
 Count elements equal e in the array.
ssize_t indexOf (const PIString &e, ssize_t start=0) const
 Returns the first index at which a given element e can be found in the array, or -1 if it is not present.
ssize_t indexWhere (std::function< bool(const PIString &e)> test, ssize_t start=0) const
 Returns the first index passes the test implemented by the provided function test, or -1 if it is not present. can be found in the array, or -1 if it is not present.
ssize_t lastIndexOf (const PIString &e, ssize_t start=-1) const
 Returns the last index at which a given element e can be found in the array, or -1 if it is not present.
ssize_t lastIndexWhere (std::function< bool(const PIString &e)> test, ssize_t start=-1) const
 Returns the last index passes the test implemented by the provided function test, or -1 if it is not present.
PIString * data (size_t index=0)
 Pointer to array.
PIDeque< PIString > getRange (size_t index, size_t count) const
 Creates sub-array of this array.
PIDeque< PIString > & clear ()
 Clear array, remove all elements.
PIDeque< PIString > & fill (const PIString &e=PIString())
 Assigns element 'e' to all items in the array.
PIDeque< PIString > & assign (const PIString &e=PIString())
 Same as fill().
PIDeque< PIString > & resize (size_t new_size, const PIString &e=PIString())
 Sets size of the array, new elements are copied from e.
PIDeque< PIString > & reserve (size_t new_size)
 Attempts to allocate memory for at least new_size elements.
PIDeque< PIString > & insert (size_t index, const PIString &e=PIString())
 Inserts value e at index position in the array.
PIDeque< PIString > & remove (size_t index, size_t count=1)
 Removes count elements from the middle of the array, starting at index position.
void swap (PIDeque< PIString > &other)
 Swaps array v other with this array.
PIDeque< PIString > & sort ()
 Sorts the elements in non-descending order.
PIDeque< PIString > & reverse ()
 Reverses this array.
PIDeque< PIString > reversed () const
 Returns reversed array.
PIDeque< PIString > & enlarge (ssize_t add_size, const PIString &e=PIString())
 Increases or decreases the size of the array by add_size elements.
PIDeque< PIString > & removeOne (const PIString &e)
 Remove no more than one element equal e.
PIDeque< PIString > & removeAll (const PIString &e)
 Remove all elements equal e.
PIDeque< PIString > & removeWhere (std::function< bool(const PIString &e)> test)
 Remove all elements in the array passes the test implemented by the provided function test.
PIDeque< PIString > & push_back (const PIString &e)
 Appends the given element e to the end of the array.
PIDeque< PIString > & append (const PIString &e)
 Appends the given element e to the end of the array.
PIDeque< PIString > & operator<< (const PIString &e)
 Appends the given element e to the end of the array.
PIDeque< PIString > & push_front (const PIString &e)
 Appends the given element e to the begin of the array.
PIDeque< PIString > & prepend (const PIString &e)
 Appends the given element e to the begin of the array.
PIDeque< PIString > & pop_back ()
 Remove one element from the end of the array.
PIDeque< PIString > & pop_front ()
 Remove one element from the begining of the array.
PIString take_back ()
 Remove one element from the end of the array and return it.
PIString take_front ()
 Remove one element from the begining of the array and return it.
PIDeque< ST > toType () const
 Returns an array converted to another type.
PIDeque< PIString > filter (std::function< bool(const PIString &e)> test) const
 Returns a new array with all elements that pass the test implemented by the provided function bool test(const T & e).
PIDeque< PIString > filterIndexed (std::function< bool(size_t index, const PIString &e)> test) const
 Same as filter() but with index parameter in test.
PIDeque< PIString > filterReverse (std::function< bool(const PIString &e)> test) const
 Same as filter() but from end to begin (from right to left).
PIDeque< PIString > filterReverseIndexed (std::function< bool(size_t index, const PIString &e)> test) const
 Same as filterReverse() but with index parameter in test.
void forEach (std::function< void(const PIString &e)> f) const
 Execute function void f(const T & e) for every element in array.
void forEachIndexed (std::function< void(size_t index, const PIString &e)> f) const
 Same as forEach() but with index parameter in f.
void forEachReverse (std::function< void(const PIString &e)> f) const
 Same as forEach() but from end to begin (from right to left).
void forEachReverseIndexed (std::function< void(size_t index, const PIString &e)> f) const
 Same as forEachIndexed() but from end to begin (from right to left).
PIDeque< ST > map (std::function< ST(const PIString &e)> f) const
 Сreates a new array populated with the results of calling a provided function ST f(const T & e) on every element in the calling array.
PIDeque< ST > mapIndexed (std::function< ST(size_t index, const PIString &e)> f) const
 Same as map() but with index parameter in f.
PIDeque< ST > mapReverse (std::function< ST(const PIString &e)> f) const
 Same as map() but from end to begin (from right to left).
PIDeque< ST > mapReverseIndexed (std::function< ST(size_t index, const PIString &e)> f) const
 Same as mapReverse() but with index parameter in f.
ST reduce (std::function< ST(const PIString &e, const ST &acc)> f, const ST &initial=ST()) const
 Applies the function ST f(const T & e, const ST & acc) to each element of the array (from left to right), returns one value.
ST reduceIndexed (std::function< ST(size_t index, const PIString &e, const ST &acc)> f, const ST &initial=ST()) const
 Same as reduce() but with index parameter in f.
ST reduceReverse (std::function< ST(const PIString &e, const ST &acc)> f, const ST &initial=ST()) const
 Same as reduce() but from end to begin (from right to left).
ST reduceReverseIndexed (std::function< ST(size_t index, const PIString &e, const ST &acc)> f, const ST &initial=ST()) const
 Same as reduceReverse() but with index parameter in f.
PIDeque< PIDeque< PIString > > reshape (size_t rows, size_t cols, ReshapeOrder order=ReshapeByRow) const
 Changes the dimension of the array, creates a two-dimensional array from a one-dimensional array.
PIDeque< C > flatten (ReshapeOrder order=ReshapeByRow) const
 Changes the dimension of the array, creates a one-dimensional array from a two-dimensional array.
PIDeque< PIDeque< PIString > > split (const PIString &separator) const
 Divides an array into a two-dimensional array using the separator separator.
PIDeque< PIDeque< PIString > > splitBySize (size_t sz) const
 Divides an array into a two-dimensional array in chunks of no more than sz.
PIDeque< PIString > takeRange (size_t index, size_t count)
 Cut sub-array of this array.

(Note that these are not member symbols.)

std::ostream & operator<< (std::ostream &s, const PIStringList &v)
 Writes PIStringList to std::ostream in brace-delimited form.

Detailed Description

Based on PIDeque<PIString> strings list.

Member Function Documentation

◆ join()

PIString PIStringList::join ( const PIString & delim) const

Join all strings in one with delimiter "delim" and returns it.

Example:

PIStringList sl("1", "2");
sl << "3";
piCout << sl.join(" < "); // 1 < 2 < 3
PIStringList()
Contructs an empty strings list.
Definition pistringlist.h:40
#define piCout
Macro used for conditional (piDebug) output to PICout(StdOut).
Definition picout.h:36

◆ removeStrings()

PIStringList & PIStringList::removeStrings ( const PIString & value)

Remove all strings equal "value" and returns reference to this.

Example:

PIStringList sl("1", "2");
sl << "1" << "2" << "3";
piCout << sl; // {"1", "2", "1", "2", "3"}
piCout << sl.removeStrings("1"); // {"2", "2", "3"}

◆ removeDuplicates()

PIStringList & PIStringList::removeDuplicates ( )

Remove duplicated strings and returns reference to this.

Example:

PIStringList sl("1", "2");
sl << "1" << "2" << "3";
piCout << sl; // {"1", "2", "1", "2", "3"}
piCout << sl.removeDuplicates(); // {"1", "2", "3"}

◆ trim()

PIStringList & PIStringList::trim ( )

Trim all strings and returns reference to this.

Example:

PIStringList sl(" 1 ", "\t2", " 3\n");
piCout << sl; // {" 1 ", " 2", " 3\n"}
piCout << sl.trim(); // {"1", "2", "3"}