STRING

pure String string();
pure String string(const char *cstr);
pure String string(char32_t c);
pure bool empty(String str);
pure const char *c_str(String str);
pure String append(String str0, String str1);
pure String append(String str0, char32_t c);
pure String append(String str0, const char *cstr);
pure String operator+(String str0, String str1);
pure String operator+(String str0, char32_t c);
pure String operator+(String str0, const char *cstr);
String &operator+=(String &str0, String str1);
String &operator+=(String &str0, char32_t c);
String &operator+=(String &str0, const char *cstr);
pure size_t size(String str);
pure Optional<char32_t> at(String s, size_t idx);
pure char32_t lookup(String s, size_t idx);
pure Optional<size_t> find(String s, String t, size_t pos = 0);
pure Optional<size_t> find(String s, const char *t, size_t pos = 0);
pure Optional<size_t> find(String s, char32_t c, size_t pos = 0);
pure Result<String, Optional<size_t>> replace(String s, String t, String r, size_t pos = 0) ;
pure Result<String, Optional<size_t>> replace(String s, const char *t, String r, size_t pos = 0) ;
pure String replace_all(String s, String t, String r, size_t pos = 0);
pure String replace_all(String s, const char *t, String r, size_t pos = 0);
pure Result<String, String> split(String s, size_t idx);
pure String left(String s, size_t idx);
pure String right(String s, size_t idx);
pure String between(String s, size_t idx, size_t count);
pure String insert(String s, size_t idx, String t);
pure String erase(String s, size_t idx, size_t count = 1);
pure String show(String str);
pure int compare(String s, String t);
template <typename T, typename F> pure T foldl(String str, const T &arg, F func);
template <typename T, typename F> pure T foldr(String str, const T &arg, F func);
template <typename F> pure String map(String str, F func);
template <typename F> pure String filter(String str, F func);
template <typename F> pure String filter_map(String str, F func);
pure bool verify(String s);
pure StringItr begin(String s);
pure StringItr end(String s);
StringItr &operator ++(StringItr &i);
StringItr &operator --(StringItr &i);
StringItr &operator +(StringItr &i, ssize_t offset);
StringItr &operator -(StringItr &i, ssize_t offset);
StringItr &operator +=(StringItr &i, ssize_t offset);
StringItr &operator -=(StringItr &i, ssize_t offset);
pure char32_t operator *(StringItr &i);
pure bool operator ==(const StringItr &i, const StringItr &j);
pure bool operator !=(const StringItr &i, const StringItr &j);

pure String string()

Construct the empty string. O(1).


pure String string(const char *cstr)

Construct a string from C-string `cstr'. O(n).


pure String string(char32_t c)

Construct a singleton string from a character `c'. O(1).


pure bool empty(String str)

Test if a string is empty. O(1).


pure const char *c_str(String str)

Convert a string into a C-string. O(n).


pure String append(String str0, String str1)

Append strings. O(min(log(n), log(m))).


pure String append(String str0, char32_t c)

Append character `c'. O(1).


pure String append(String str0, const char *cstr)

Append C-string `cstr'. O(n), n = len(cstr).


pure String operator+(String str0, String str1)

Alias of `append'. O(min(log(n), log(m))).


pure String operator+(String str0, char32_t c)

Alias of `append'. O(1).


pure String operator+(String str0, const char *cstr)

Alias of `append'. O(n), n = len(cstr).


String &operator+=(String &str0, String str1)

Destructively append strings. O(min(log(n), log(m))).


String &operator+=(String &str0, char32_t c)

Destructively append character `c'. O(1).


String &operator+=(String &str0, const char *cstr)

Destructively append C-string `cstr'. O(n), n = len(cstr).


pure size_t size(String str)

String size (a.k.a. string length). O(1).


pure Optional<char32_t> at(String s, size_t idx)

Get the character at index `idx'. O(log(n)).


pure char32_t lookup(String s, size_t idx)

Get the character at index `idx'. O(log(n)).


pure Optional<size_t> find(String s, String t, size_t pos = 0)

Find the first occurence of a sub-string. O(n.m.log(m)), m = len(t).


pure Optional<size_t> find(String s, const char *t, size_t pos = 0)

Find the first occurence of a C-sub-string. O(n.m), m = len(t).


pure Optional<size_t> find(String s, char32_t c, size_t pos = 0)

Find the first occurence of the character `c'. O(n).


pure Result<String, Optional<size_t>> replace(String s, String t, String r, size_t pos = 0) 

Replace the first occurence of sub-string `t' with string `r'.


pure Result<String, Optional<size_t>> replace(String s, const char *t, String r, size_t pos = 0) 

Replace the first occurence of C-sub-string `t' with string `r'.


pure String replace_all(String s, String t, String r, size_t pos = 0)

Replace all occurences of sub-string `t' with string `r'.


pure String replace_all(String s, const char *t, String r, size_t pos = 0)

Replace all occurences of C-sub-string `t' with string `r'.


pure Result<String, String> split(String s, size_t idx)

Split. O(log(n)).


pure String left(String s, size_t idx)

Left split. O(log(n)).


pure String right(String s, size_t idx)

Right split. O(log(n)).


pure String between(String s, size_t idx, size_t count)

Extract the sub-string at `idx' with `count' characters. O(log(n)).


pure String insert(String s, size_t idx, String t)

Insert the string `t' at index `idx'. O(log(n)).


pure String erase(String s, size_t idx, size_t count = 1)

Erase the sub-string at `idx' with `count' characters. O(log(n)).


pure String show(String str)

String show. O(n).


pure int compare(String s, String t)

String compare. O(n).


template <typename T, typename F>
pure T foldl(String str, const T &arg, F func)

String fold left. ([](T, size_t idx, char32_t c) -> T). O(n).


template <typename T, typename F>
pure T foldr(String str, const T &arg, F func)

String fold right. ([](T, size_t idx, char32_t c) -> T). O(n).


template <typename F>
pure String map(String str, F func)

String map. ([](size_t idx, char32_t c) -> char32_t). O(n).


template <typename F>
pure String filter(String str, F func)

String filter. ([](size_t idx, char32_t c) -> bool). O(n).


template <typename F>
pure String filter_map(String str, F func)

String filter map. ([](size_t idx, char32_t c) -> Optional<char32_t>). O(n).


pure bool verify(String s)

Verify. O(n).


pure StringItr begin(String s)

Construct an iterator pointing to the start of a string. O(1).


pure StringItr end(String s)

Construct an iterator pointing to the end of a string. O(1).


StringItr &operator ++(StringItr &i)

String iterator increment. O(1).


StringItr &operator --(StringItr &i)

String iterator decrement. O(1).


StringItr &operator +(StringItr &i, ssize_t offset)

String iterator add offset. O(log(offset)).


StringItr &operator -(StringItr &i, ssize_t offset)

String iterator substract offset. O(log(offset))


StringItr &operator +=(StringItr &i, ssize_t offset)

String iterator add offset. O(log(offset))


StringItr &operator -=(StringItr &i, ssize_t offset)

String iterator subtract offset. O(log(offset))


pure char32_t operator *(StringItr &i)

String iterator dereference. O(log(delta)), where delta is distance to last dereference.


pure bool operator ==(const StringItr &i, const StringItr &j)

String iterator same offset. O(1).


pure bool operator !=(const StringItr &i, const StringItr &j)

String iterator different offset. O(1).