C++ API Reference
MUniqueString Class Reference

A non-mutable string with O(1) comparison operators. More...

#include <MUniqueString.h>

Public Member Functions

 MUniqueString ()
 The Class constructor. More...
 
 MUniqueString (const MUniqueString &)
 Copy constructor. More...
 
 ~MUniqueString ()
 Destructor. More...
 
 MUniqueString (MUniqueString &&)
 Move constructor. More...
 
MUniqueStringoperator= (MUniqueString &&)
 Move assignment. More...
 
const MStringstring () const
 Return a constant MString which is equal to the MString used to create this MUniqueString. More...
 
size_t hash () const
 
bool operator== (const MUniqueString &other) const
 Two MUniqueString instance are equal if and only if their underlying string values are equal. More...
 
bool operator!= (const MUniqueString &other) const
 Two MUniqueString instance are not equal if and only if their underlying string values are not equal. More...
 
bool operator> (const MUniqueString &other) const
 This comparison operator does not compare the underlying string values of the MUniqueString instances. More...
 
bool operator>= (const MUniqueString &other) const
 This comparison operator does not compare the underlying string values of the MUniqueString instances. More...
 
bool operator< (const MUniqueString &other) const
 This comparison operator does not compare the underlying string values of the MUniqueString instances. More...
 
bool operator<= (const MUniqueString &other) const
 This comparison operator does not compare the underlying string values of the MUniqueString instances. More...
 
bool operator== (const MString &other) const
 This comparison operator compares the underlying string value of the MUniqueString instance and the MString. More...
 
bool operator== (const char *other) const
 This comparison operator compares the underlying string value of the MUniqueString instance and the char*. More...
 
bool operator!= (const MString &other) const
 This comparison operator compares the underlying string value of the MUniqueString instance and the MString. More...
 
bool operator!= (const char *other) const
 This comparison operator compares the underlying string value of the MUniqueString instance and the char*. More...
 

Static Public Member Functions

static MUniqueString intern (const MString &s)
 Create an MUniqueString from the given MString s. More...
 

Detailed Description

A non-mutable string with O(1) comparison operators.

MUniqueString is a non-mutable string class which provides an O(1) equality operator, comparison operators and hash function.

Two MUniqueString instances are equal if and only if their underlying string values are equal.

operator>, operator>=, operator< and operator<= do not compare the underlying string values of the MUniqueStrings. The ordering produced by MUniqueString comparison methods does not necessarily match the ordering produced by typical string comparison operators.

MUniqueString is not order-preserving. MString A < MString B does not imply MUniqueString::intern(A) < MUniqueString::intern(B).

The hash value is not deterministically computed from the underlying string value. The hash value of all existing MUniqueString instances are guaranteed to match if the underlying string values of the instances are equal. It is not safe to store the hash value of an MUniqueString after it has been deleted. The hash value of of a deleted MUniqueString is not guaranteed to match a newly created MUniqueString with the same underlying string value as the original deleted MUniqueString instance.

Constructor & Destructor Documentation

OPENMAYA_MAJOR_NAMESPACE_OPEN MUniqueString ( )

The Class constructor.

Initializes the new MUniqueString instance to the empty string.

This function may perform global synchronization and is slow.

MUniqueString ( const MUniqueString other)

Copy constructor.

Initialize the new MUniqueString instance be to equal to the existing MUniqueString.

This function may perform global synchronization and is slow.

Parameters
[in]otherMUniqueString instance copied to construct this MUniqueString.

Destructor.

This function may perform global synchronization and is slow.

Move constructor.

Parameters
[in]otherrvalue used to construct this MUniqueString.

Member Function Documentation

MUniqueString intern ( const MString s)
static

Create an MUniqueString from the given MString s.

This function will access and possibly modify the global MUniqueString table so calls to this function are slow.

This function may perform global synchronization and is slow.

Parameters
[in]sThe string to be made unique.
Returns
An MUniqueString with value s.
MUniqueString & operator= ( MUniqueString &&  other)

Move assignment.

Parameters
[in]otherrvalue assigned to this MUniqueString.
const MString & string ( ) const

Return a constant MString which is equal to the MString used to create this MUniqueString.

Modifying the returned MString has undefined behavior.

Returns
An MString equal to the original MString used to create this MUniqueString.
size_t hash ( ) const
Returns
A unique value based on the contents of the MUniqueString
bool operator== ( const MUniqueString other) const

Two MUniqueString instance are equal if and only if their underlying string values are equal.

Parameters
[in]otherMUniqueString compared to this MUniqueString.
Returns
true if the MUniqueString objects are equal.
bool operator!= ( const MUniqueString other) const

Two MUniqueString instance are not equal if and only if their underlying string values are not equal.

Parameters
[in]otherMUniqueString compared to this MUniqueString.
Returns
true if the MUniqueString objects are not equal.
bool operator> ( const MUniqueString other) const

This comparison operator does not compare the underlying string values of the MUniqueString instances.

Parameters
[in]otherMUniqueString compared to this MUniqueString.
Returns
true if this MUniqueString is greater than other.
bool operator>= ( const MUniqueString other) const

This comparison operator does not compare the underlying string values of the MUniqueString instances.

Parameters
[in]otherMUniqueString compared to this MUniqueString.
Returns
true if this MUniqueString is greater than or equal to other.
bool operator< ( const MUniqueString other) const

This comparison operator does not compare the underlying string values of the MUniqueString instances.

Parameters
[in]otherMUniqueString compared to this MUniqueString.
Returns
true if this MUniqueString is less than other.
bool operator<= ( const MUniqueString other) const

This comparison operator does not compare the underlying string values of the MUniqueString instances.

Parameters
[in]otherMUniqueString compared to this MUniqueString.
Returns
true if this MUniqueString is less than or equal to other.
bool operator== ( const MString other) const

This comparison operator compares the underlying string value of the MUniqueString instance and the MString.

This function is linear in the number of characters in other.

Parameters
[in]otherMString instance compared to this MUniqueString.
Returns
true if this MUniqueString is equal to other.
bool operator== ( const char *  other) const

This comparison operator compares the underlying string value of the MUniqueString instance and the char*.

This function is linear in the number of characters in other.

Parameters
[in]otherchar* value compared to this MUniqueString.
Returns
true if this MUniqueString is equal to other.
bool operator!= ( const MString other) const

This comparison operator compares the underlying string value of the MUniqueString instance and the MString.

This function is linear in the number of characters in other.

Parameters
[in]otherMString instance compared to this MUniqueString.
Returns
true if this MUniqueString is equal to other.
bool operator!= ( const char *  other) const

This comparison operator compares the underlying string value of the MUniqueString instance and the char*.

This function is linear in the number of characters in other.

Parameters
[in]otherchar* value compared to this MUniqueString.
Returns
true if this MUniqueString is equal to other.

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