scire
Sadh's C++ Impromptu Routines Ensemble
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
scire::CharStringUtil Class Reference

#include <cstr_util.hpp>

Static Public Member Functions

static bool IsAllCharUnique (const char str[])
 check if all characater in a string is unique More...
 
static void Reverse (char str[])
 reverse the passed string More...
 
template<size_t N>
static bool IsPermutation (const char a[], const char b[])
 check if a string passed is a permutation of the other More...
 
static size_t Replace (const char subject[], char result[], char search, char replace[])
 replace all occurrences of a character with some string More...
 
template<typename Type >
static size_t NumToDecimalString (Type num, char str[])
 
static size_t CharCountEncoding (const char subject[], char encstr[])
 encode a string such that every repeated character is encoded as the character followed by count. More...
 
static size_t CharCountCompress (const char subject[], char compstr[])
 compress a string such that every repeated character is encoded as the character followed by count. More...
 
static size_t StrPos (const char *haystack, const char *needle, size_t offset=0)
 Find the position of the first occurrence of a substring in a text. More...
 
static bool isSubstring (const char *string, const char *substring)
 check if a string is a substring of other More...
 
static bool isRotation (const char *str, const char *rstr)
 check if a string is a roation of another More...
 

Detailed Description

Definition at line 33 of file cstr_util.hpp.

Member Function Documentation

static size_t scire::CharStringUtil::CharCountCompress ( const char  subject[],
char  compstr[] 
)
inlinestatic

compress a string such that every repeated character is encoded as the character followed by count.

e.g. aabcccaaaa -> a2b1c3a4. If encoded string is not smaller then return original string.

Returns
lenght of encoded string
Parameters
subjectstring to encode
compstrencoded string

Definition at line 183 of file cstr_util.hpp.

static size_t scire::CharStringUtil::CharCountEncoding ( const char  subject[],
char  encstr[] 
)
inlinestatic

encode a string such that every repeated character is encoded as the character followed by count.

e.g. aabcccaaaa -> a2b1c3a4

Returns
lenght of encoded string
Parameters
subjectstring to encode
encstrencoded string

Definition at line 149 of file cstr_util.hpp.

static bool scire::CharStringUtil::IsAllCharUnique ( const char  str[])
inlinestatic

check if all characater in a string is unique

Returns
false if at least one char appear more than once in the string
Parameters
strstring to check

Definition at line 40 of file cstr_util.hpp.

template<size_t N>
static bool scire::CharStringUtil::IsPermutation ( const char  a[],
const char  b[] 
)
inlinestatic

check if a string passed is a permutation of the other

Definition at line 73 of file cstr_util.hpp.

static bool scire::CharStringUtil::isRotation ( const char *  str,
const char *  rstr 
)
inlinestatic

check if a string is a roation of another

Definition at line 228 of file cstr_util.hpp.

static bool scire::CharStringUtil::isSubstring ( const char *  string,
const char *  substring 
)
inlinestatic

check if a string is a substring of other

Parameters
stringtext to find substring in (haystack)
substringsubstring to look for (needle)

Definition at line 216 of file cstr_util.hpp.

template<typename Type >
static size_t scire::CharStringUtil::NumToDecimalString ( Type  num,
char  str[] 
)
inlinestatic

Definition at line 124 of file cstr_util.hpp.

static size_t scire::CharStringUtil::Replace ( const char  subject[],
char  result[],
char  search,
char  replace[] 
)
inlinestatic

replace all occurrences of a character with some string

Parameters
subjectstring to operate on
resultresult string
searchcharacter to replace
replacestring to replace with

Definition at line 99 of file cstr_util.hpp.

static void scire::CharStringUtil::Reverse ( char  str[])
inlinestatic

reverse the passed string

Parameters
strstring to reverse

Definition at line 58 of file cstr_util.hpp.

static size_t scire::CharStringUtil::StrPos ( const char *  haystack,
const char *  needle,
size_t  offset = 0 
)
inlinestatic

Find the position of the first occurrence of a substring in a text.

Returns
position (index) of first occurrence of substring in text if found, if not found then the lenght of text
Parameters
haystacktext to search in
needlesubstring to look for
offsetoffset to start search from

Definition at line 204 of file cstr_util.hpp.


The documentation for this class was generated from the following file: