PIP 5.5.3
Platform-Independent Primitives
Public Member Functions | Related Functions | List of all members
PIStringList Class Reference

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

#include <pistringlist.h>

Inheritance diagram for PIStringList:
Inheritance graph
[legend]

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. More...
 
PIStringListremoveStrings (const PIString &value)
 Remove all strings equal "value" and returns reference to this. More...
 
PIStringListremoveDuplicates ()
 Remove duplicated strings and returns reference to this. More...
 
PIStringListtrim ()
 Trim all strings and returns reference to this. More...
 
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.
 
PIStringListoperator= (const PIStringList &o)
 Assign operator.
 
PIStringListoperator<< (const PIString &str)
 Append string "str".
 
PIStringListoperator<< (const PIStringList &sl)
 Append strings list "sl".
 
- Public Member Functions inherited from PIDeque< PIString >
 PIDeque ()
 Constructs an empty array.
 
 PIDeque (const PIDeque< PIString > &other)
 Copy constructor.
 
 PIDeque (std::initializer_list< PIString > init_list)
 Contructs array from C++11 initializer list. More...
 
 PIDeque (const PIString *data, size_t size)
 Contructs array from raw data. This constructor reserve size and copy from data pointer.
 
 PIDeque (size_t pid_size, const PIString &e=PIString())
 Contructs array with size size filled elements e.
 
 PIDeque (size_t piv_size, std::function< PIString(size_t i)> f)
 Contructs array with size size and elements created by function f(size_t i). More...
 
 PIDeque (PIDeque< PIString > &&other)
 Move constructor.
 
PIDeque< PIString > & operator= (const PIDeque< PIString > &other)
 Assign operator.
 
PIDeque< PIString > & operator= (PIDeque< PIString > &&other)
 Assign move operator.
 
iterator begin ()
 Iterator to the first element. More...
 
iterator end ()
 Iterator to the element following the last element. More...
 
reverse_iterator rbegin ()
 Returns a reverse iterator to the first element of the reversed array. More...
 
reverse_iterator rend ()
 Returns a reverse iterator to the element. following the last element of the reversed array. More...
 
size_t size () const
 Number of elements in the container. More...
 
ssize_t size_s () const
 Number of elements in the container as signed value. More...
 
size_t length () const
 Same as size(). More...
 
size_t capacity () const
 Number of elements that the container has currently allocated space for. More...
 
bool isEmpty () const
 Checks if the container has no elements. More...
 
bool isNotEmpty () const
 Checks if the container has elements. More...
 
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. More...
 
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. More...
 
PIStringoperator[] (size_t index)
 Full access to element by index. More...
 
const PIStringat (size_t index) const
 Read only access to element by index. More...
 
const PIStringatWhere (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. More...
 
const PIStringlastAtWhere (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. More...
 
PIStringback ()
 Last element. More...
 
PIStringfront ()
 Last element. More...
 
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. More...
 
bool contains (const PIDeque< PIString > &v, ssize_t start=0) const
 Tests if all elements of v exists in the array. More...
 
int entries (const PIString &e, ssize_t start=0) const
 Count elements equal e in the array. More...
 
int entries (std::function< bool(const PIString &e)> test, ssize_t start=0) const
 Count elements in the array passes the test implemented by the provided function test. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
PIStringdata (size_t index=0)
 Pointer to array. More...
 
const PIStringdata (size_t index=0) const
 Read only pointer to array. More...
 
PIDeque< PIStringgetRange (size_t index, size_t count) const
 Creates sub-array of this array. More...
 
PIDeque< PIString > & clear ()
 Clear array, remove all elements. More...
 
PIDeque< PIString > & fill (const PIString &e=PIString())
 Assigns element 'e' to all items in the array. More...
 
PIDeque< PIString > & fill (std::function< PIString(size_t i)> f)
 Assigns result of function 'f(size_t i)' to all items in the array. More...
 
PIDeque< PIString > & assign (const PIString &e=PIString())
 Same as fill(). More...
 
PIDeque< PIString > & assign (size_t new_size, const PIString &e)
 First does resize(new_size) then fill(e). More...
 
PIDeque< PIString > & resize (size_t new_size, const PIString &e=PIString())
 Sets size of the array, new elements are copied from e. More...
 
PIDeque< PIString > & resize (size_t new_size, std::function< PIString(size_t i)> f)
 Sets size of the array, new elements created by function f(size_t i). More...
 
PIDeque< PIString > & reserve (size_t new_size)
 Attempts to allocate memory for at least new_size elements. More...
 
PIDeque< PIString > & insert (size_t index, const PIString &e=PIString())
 Inserts value e at index position in the array. More...
 
PIDeque< PIString > & insert (size_t index, PIString &&e)
 Inserts value e at index position in the array. More...
 
PIDeque< PIString > & insert (size_t index, const PIDeque< PIString > &v)
 Inserts array v at index position in the array. More...
 
PIDeque< PIString > & insert (size_t index, std::initializer_list< PIString > init_list)
 Inserts the given elements at index position in the array. More...
 
PIDeque< PIString > & remove (size_t index, size_t count=1)
 Removes count elements from the middle of the array, starting at index position. More...
 
void swap (PIDeque< PIString > &other)
 Swaps array v other with this array. More...
 
PIDeque< PIString > & sort ()
 Sorts the elements in non-descending order. More...
 
PIDeque< PIString > & sort (std::function< bool(const PIString &a, const PIString &b)> comp)
 Sorts the elements in non-descending order. More...
 
PIDeque< PIString > & reverse ()
 Reverses this array. More...
 
PIDeque< PIStringreversed () const
 Returns reversed array. More...
 
PIDeque< PIString > & enlarge (ssize_t add_size, const PIString &e=PIString())
 Increases or decreases the size of the array by add_size elements. More...
 
PIDeque< PIString > & removeOne (const PIString &e)
 Remove no more than one element equal e. More...
 
PIDeque< PIString > & removeAll (const PIString &e)
 Remove all elements equal e. More...
 
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. More...
 
PIDeque< PIString > & push_back (const PIString &e)
 Appends the given element e to the end of the array. More...
 
PIDeque< PIString > & push_back (PIString &&e)
 Appends the given element e to the end of the array. More...
 
PIDeque< PIString > & push_back (std::initializer_list< PIString > init_list)
 Appends the given elements to the end of the array. More...
 
PIDeque< PIString > & push_back (const PIDeque< PIString > &v)
 Appends the given array v to the end of the array. More...
 
PIDeque< PIString > & append (const PIString &e)
 Appends the given element e to the end of the array. More...
 
PIDeque< PIString > & append (PIString &&e)
 Appends the given element e to the end of the array. More...
 
PIDeque< PIString > & append (std::initializer_list< PIString > init_list)
 Appends the given elements to the end of the array. More...
 
PIDeque< PIString > & append (const PIDeque< PIString > &v)
 Appends the given array v to the end of the array. More...
 
PIDeque< PIString > & operator<< (const PIString &e)
 Appends the given element e to the end of the array. More...
 
PIDeque< PIString > & operator<< (PIString &&e)
 Appends the given element e to the end of the array. More...
 
PIDeque< PIString > & operator<< (const PIDeque< PIString > &v)
 Appends the given array v to the end of the array. More...
 
PIDeque< PIString > & push_front (const PIString &e)
 Appends the given element e to the begin of the array. More...
 
PIDeque< PIString > & push_front (PIString &&e)
 Appends the given element e to the begin of the array. More...
 
PIDeque< PIString > & push_front (const PIDeque< PIString > &v)
 Appends the given array v to the begin of the array. More...
 
PIDeque< PIString > & push_front (std::initializer_list< PIString > init_list)
 Appends the given elements to the begin of the array. More...
 
PIDeque< PIString > & prepend (const PIString &e)
 Appends the given element e to the begin of the array. More...
 
PIDeque< PIString > & prepend (PIString &&e)
 Appends the given element e to the begin of the array. More...
 
PIDeque< PIString > & prepend (const PIDeque< PIString > &v)
 Appends the given array v to the begin of the array. More...
 
PIDeque< PIString > & prepend (std::initializer_list< PIString > init_list)
 Appends the given elements to the begin of the array. More...
 
PIDeque< PIString > & pop_back ()
 Remove one element from the end of the array. More...
 
PIDeque< PIString > & pop_front ()
 Remove one element from the begining of the array. More...
 
PIString take_back ()
 Remove one element from the end of the array and return it. More...
 
PIString take_front ()
 Remove one element from the begining of the array and return it. More...
 
PIDeque< ST > toType () const
 Returns an array converted to another type. More...
 
PIDeque< PIStringfilter (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). More...
 
PIDeque< PIStringfilterIndexed (std::function< bool(size_t index, const PIString &e)> test) const
 Same as filter() but with index parameter in test. More...
 
PIDeque< PIStringfilterReverse (std::function< bool(const PIString &e)> test) const
 Same as filter() but from end to begin (from right to left). More...
 
PIDeque< PIStringfilterReverseIndexed (std::function< bool(size_t index, const PIString &e)> test) const
 Same as filterReverse() but with index parameter in test. More...
 
void forEach (std::function< void(const PIString &e)> f) const
 Execute function void f(const T & e) for every element in array. More...
 
PIDeque< PIString > & forEach (std::function< void(PIString &e)> f)
 Execute function void f(T & e) for every element in array. More...
 
void forEachIndexed (std::function< void(size_t index, const PIString &e)> f) const
 Same as forEach() but with index parameter in f. More...
 
PIDeque< PIString > & forEachIndexed (std::function< void(size_t index, PIString &e)> f)
 Same as forEachIndexed(), but allows you to change the elements of the array. More...
 
void forEachReverse (std::function< void(const PIString &e)> f) const
 Same as forEach() but from end to begin (from right to left). More...
 
PIDeque< PIString > & forEachReverse (std::function< void(PIString &e)> f)
 Same as forEachReverse(), but allows you to change the elements of the array. More...
 
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). More...
 
PIDeque< PIString > & forEachReverseIndexed (std::function< void(size_t index, PIString &e)> f)
 Same as forEachReverseIndexed(), but allows you to change the elements of the array. More...
 
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. More...
 
PIDeque< ST > mapIndexed (std::function< ST(size_t index, const PIString &e)> f) const
 Same as map() but with index parameter in f. More...
 
PIDeque< ST > mapReverse (std::function< ST(const PIString &e)> f) const
 Same as map() but from end to begin (from right to left). More...
 
PIDeque< ST > mapReverseIndexed (std::function< ST(size_t index, const PIString &e)> f) const
 Same as mapReverse() but with index parameter in f. More...
 
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. More...
 
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. More...
 
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). More...
 
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. More...
 
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. More...
 
PIDeque< PIDeque< C > > reshape (size_t rows, size_t cols, ReshapeOrder order=ReshapeByRow) const
 Changes the dimension of the two-dimensional array. More...
 
PIDeque< C > flatten (ReshapeOrder order=ReshapeByRow) const
 Changes the dimension of the array, creates a one-dimensional array from a two-dimensional array. More...
 
PIDeque< PIDeque< PIString > > split (const PIString &separator) const
 Divides an array into a two-dimensional array using the separator separator. More...
 
PIDeque< PIDeque< PIString > > splitBySize (size_t sz) const
 Divides an array into a two-dimensional array in chunks of no more than sz. More...
 
PIDeque< PIStringtakeRange (size_t index, size_t count)
 Cut sub-array of this array. More...
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &s, const PIStringList &v)
 Output operator to std::ostream (cout)
 

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
Based on PIDeque<PIString> strings list.
Definition: pistringlist.h:36
#define piCout
Macro used for conditional (piDebug) output to PICout(StdOut)
Definition: picout.h:35

◆ 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"}