Loading...
Searching...
No Matches
SBCContainerFractionalKey Class Reference

This class describes a fractional key used for assigning a unique index to nodes and sort them in a context of collaborative editing. More...

Validity

static const SBCContainerFractionalKey zero
 The zero fractional key.
 
static const SBCContainerFractionalKey one
 The one fractional key.
 
bool isValid () const
 Returns true if and only if the fractional key is valid.
 

Constructors and destructors

 SBCContainerFractionalKey (char c)
 Constructs a fractional key from a char.
 
 SBCContainerFractionalKey (const SBCContainerVector< char > &charVector)
 Constructs a fractional key from a vector of chars.
 
 SBCContainerFractionalKey (const std::string &key)
 Constructs a fractional key from a std::string.
 
 SBCContainerFractionalKey (const SBCContainerFractionalKey &other)
 Copy constructor.
 
 SBCContainerFractionalKey (SBCContainerFractionalKey &&other)
 Move constructor.
 
 SBCContainerFractionalKey ()
 Constructs an invalid fractional key.
 
virtual ~SBCContainerFractionalKey ()
 Destructs the fractional key.
 

Operators

SBCContainerFractionalKeyoperator= (const SBCContainerFractionalKey &other)
 Copy assignment operator.
 
SBCContainerFractionalKeyoperator= (SBCContainerFractionalKey &&other)
 Move assignment operator.
 
bool operator== (const SBCContainerFractionalKey &other) const
 Equality operator.
 
bool operator!= (const SBCContainerFractionalKey &other) const
 Non-equality operator.
 
bool operator< (const SBCContainerFractionalKey &other) const
 Lexicographic comparison with another fractional key.
 
bool operator> (const SBCContainerFractionalKey &other) const
 Lexicographic comparison with another fractional key.
 
bool operator<= (const SBCContainerFractionalKey &other) const
 Lexicographic comparison with another fractional key.
 
bool operator>= (const SBCContainerFractionalKey &other) const
 Lexicographic comparison with another fractional key.
 
SBCContainerFractionalKey operator| (const SBCContainerFractionalKey &other) const
 Generate a key between this fractional and another fractional key.
 
std::string operator() () const
 Returns the fractional key in string format.
 

Detailed Description

SBCContainerFractionalKey objects can hold fractional keys (also called fractional indices). Fractional keys are arbitrary-precision fractions between 0 and 1 (excluding 0 and 1). For compactness, fractional keys only store the decimal part of the fraction, and are stored as series of printable ASCII characters (ASCII codes 32-126 included), resulting in a base-95 representation.

The number 0 is represented by an empty key, while the number 1 is represented by a key containing the char 127 only. Both 0 and 1 are not considered valid fractional keys.

Short name: SBFractionalKey