JUCE
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines
Public Member Functions
StringPool Class Reference

A StringPool holds a set of shared strings, which reduces storage overheads and improves comparison speed when dealing with many duplicate strings. More...

List of all members.

Public Member Functions

 StringPool () noexcept
 Creates an empty pool.
 ~StringPool ()
 Destructor.
String::CharPointerType getPooledString (const String &original)
 Returns a pointer to a copy of the string that is passed in.
String::CharPointerType getPooledString (const char *original)
 Returns a pointer to a copy of the string that is passed in.
String::CharPointerType getPooledString (const wchar_t *original)
 Returns a pointer to a copy of the string that is passed in.
int size () const noexcept
 Returns the number of strings in the pool.
String::CharPointerType operator[] (int index) const noexcept
 Returns one of the strings in the pool, by index.

Detailed Description

A StringPool holds a set of shared strings, which reduces storage overheads and improves comparison speed when dealing with many duplicate strings.

When you add a string to a pool using getPooledString, it'll return a character array containing the same string. This array is owned by the pool, and the same array is returned every time a matching string is asked for. This means that it's trivial to compare two pooled strings for equality, as you can simply compare their pointers. It also cuts down on storage if you're using many copies of the same string.


Constructor & Destructor Documentation

Creates an empty pool.

Destructor.


Member Function Documentation

Returns a pointer to a copy of the string that is passed in.

The pool will always return the same pointer when asked for a string that matches it. The pool will own all the pointers that it returns, deleting them when the pool itself is deleted.

Returns a pointer to a copy of the string that is passed in.

The pool will always return the same pointer when asked for a string that matches it. The pool will own all the pointers that it returns, deleting them when the pool itself is deleted.

Returns a pointer to a copy of the string that is passed in.

The pool will always return the same pointer when asked for a string that matches it. The pool will own all the pointers that it returns, deleting them when the pool itself is deleted.

int StringPool::size ( ) const

Returns the number of strings in the pool.

String::CharPointerType StringPool::operator[] ( int  index) const

Returns one of the strings in the pool, by index.


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