Definition
An instance s of the data type string is a sequence of characters (type char). The number of characters in the sequence is called the length of s. A string of length zero is called the empty string. Strings can be used wherever a C++ const char* string can be used.
Strings differ from the C++ type char* in several aspects: parameter passing by value and assignment works properly (i.e., the value is passed or assigned and not a pointer to the value) and strings offer many additional operations.
#include < LEDA/string.h >
Types
| string::size_type | the size type. |
Creation
| string | s | introduces a variable s of type string. s is initialized with the empty string. |
| string | s(const char* p) | introduces a variable s of type string. s is initialized with a copy of the C++ string p. |
| string | s(char c) | introduces a variable s of type string. s is initialized with the one-character string ``c''. |
| string | s(const char* format, ...) | |
| introduces a variable s of type string. s is initialized with the string produced by printf(format,...). | ||
Operations
Implementation
Strings are implemented by C++ character vectors. All operations involving the search for a pattern s1 in a string s take time O(s.lenght()*s1.length()), [ ] takes constant time and all other operations on a string s take time O(s.length()).
© Copyright 1995-2002, Algorithmic Solutions Software GmbH. All rights reserved.
2002-10-16