int |
s.length() |
returns the length of string s.
|
bool |
s.empty() |
returns whether s is the empty string.
|
char |
s.char_at(int i) |
returns the character at position i.
Precondition
0 < = i < = s.length()-1.
|
char |
s[int i] |
returns
s.charat(i).
|
char& |
s[int i] |
returns a reference to the character at position i.
Precondition
0 < = i < = s.length()-1.
|
string |
s.substring(int i, int j) |
returns the substring of s starting at
position max(0, i) and ending at
position min(j, s.length()) - 1.
|
string |
s.substring(int i) |
returns the substring of s starting at position max(0, i).
|
string |
s(int i, int j) |
returns the substring of s starting at
position max(0, i) and ending at
position min(j, s.length()-1).
If min(j, s.length()
-1) < max(0, i)
then the empty string is returned.
|
string |
s.head(int i) |
returns the first i characters of s if
i > = 0 and the first (
length() + i) characters of s
if i < 0.
|
string |
s.tail(int i) |
returns the last i characters of s if
i > = 0 and the last (
length() + i) characters of s
if i < 0.
|
int |
s.index(string x, int i) |
returns the minimum j such that j > = i and x
is a substring of s starting at position j
(returns -1 if no such j exists).
|
int |
s.index(const string& x) |
returns s.index(x, 0).
|
int |
s.index(char c, int i) |
returns the minimum j such that j > = i and s[j] = c
(-1 if no such j exists).
|
int |
s.index(char c) |
returns s.index(c, 0).
|
int |
s.last_index(string x, int i) |
|
|
returns the maximum j such that j < = i and x
is a substring of s starting at position j
(returns -1 if no such j exists).
|
int |
s.last_index(const string& x) |
|
|
returns s.last_index
(x, s.length() - 1).
|
int |
s.last_index(char c, int i) |
|
|
returns the maximum j such that j < = i and s[j] = c
(-1 if no such j exists).
|
int |
s.last_index(char c) |
returns s.last_index
(c, s.length() - 1).
|
string |
s.next_word(int& i, char sep) |
|
|
returns word (substring separated by sep characters)
starting at index i and assigns start of next
word to i (-1 if not existing).
|
int |
s.split(string* A, int sz, char sep=-1) |
|
|
splits s into substrings separated by sep characters
or white space (if sep = - 1) and stores them in the
array
A[0..sz - 1]. The operation returns the number of
created substrings (at most sz).
PreconditionA is an array of length sz.
|
int |
s.count_words(char sep=-1) |
|
|
returns the number of substrings separated by sep
characters or white space (if sep = - 1).
|
int |
s.break_into_words(string* A, int sz) |
|
|
breaks s into words separated by white space characters
and stores them in the array A. Same as s.split(A, sz, - 1)
|
string |
s.expand_tabs(int tab_w) |
return the result of expanding all tabs in s using
tabulator width tabw.
|
bool |
s.contains(const string& x) |
|
|
true iff x is a substring of s.
|
bool |
s.starts_with(const string& x) |
|
|
true iff s starts with x.
|
bool |
s.begins_with(const string& x) |
|
|
true iff s starts with x.
|
bool |
s.ends_with(const string& x) |
|
|
true iff s starts with x.
|
string |
s.insert(int i, string x) |
returns s(0, i - 1) + s1 + s(i, s.length()-1).
|
string |
s.replace(const string& s1, const string& s2, int i=1) |
|
|
returns the string created from s by replacing
the i-th occurrence of s1 in s by s2.
Remark: The occurences of s1 in s are counted in a
non-overlapping manner, for instance the string sasas
contains only one occurence of the string sas.
|
string |
s.replace(int i, int j, const string& x) |
|
|
returns the string created from s by replacing
s(i, j) by x.
Preconditioni < = j.
|
string |
s.replace(int i, const string& x) |
|
|
returns the string created from s by replacing
s[i] by x.
|
string |
s.replace_all(const string& s1, const string& s2) |
|
|
returns the string created from s by replacing
all occurrences of s1 in s by s2.
PreconditionThe occurrences of s1 in s
do not overlap (it's hard to say what the function returns
if the precondition is violated.).
|
string |
s.del(const string& x, int i=1) |
|
|
returns s.replace(x,"", i).
|
string |
s.del(int i, int j) |
returns s.replace(i, j,"").
|
string |
s.del(int i) |
returns s.replace(i,"").
|
string |
s.del_all(const string& x) |
|
|
returns s.replace_all(x,"").
|
void |
s.read(istream& I, char delim = ' ') |
|
|
reads characters from input stream I into s
until the first occurrence of character delim.
(If delim is '
\ n' it is extracted
from the stream, otherwise it remains there.)
|
void |
s.read(char delim = ' ') |
same as s.read(cin,delim).
|
void |
s.read_line(istream& I) |
same as s.read(I,'
\ n').
|
void |
s.read_line() |
same as s.read_line(cin).
|
void |
s.read_file(istream& I) |
same as s.read(I,'EOF').
|
void |
s.read_file() |
same as s.read_file(cin).
|
string& |
s += const string& x |
appends x to s and returns a reference to s.
|
string |
const string& x + const string& y |
|
|
returns the concatenation of x and y.
|
bool |
const string& x == const string& y |
|
|
true iff x and y are equal.
|
bool |
const string& x != const string& y |
|
|
true iff x and y are not equal.
|
bool |
const string& x < const string& y |
|
|
true iff x is lexicographically smaller than y.
|
bool |
const string& x > const string& y |
|
|
true iff x is lexicographically greater than y.
|
bool |
const string& x <= const string& y |
|
|
returns
(x < y) | (x = = y).
|
bool |
const string& x >= const string& y |
|
|
returns
(x > y) | (x = = y).
|
istream& |
istream& I » string& s |
same as s.read(I,' ').
|
ostream& |
ostream& O « const string& s |
|
|
writes string s to the output stream O.
|