Class SBCContainerFractionalKey#
ClassList > SBCContainerFractionalKey
This class describes a fractional key used for assigning a unique index to nodes and sort them in a context of collaborative editing. More...
#include <SBCContainerFractionalKey.hpp>
Public Static Attributes#
| Type | Name |
|---|---|
| const SBCContainerFractionalKey | one The one fractional key. |
| const SBCContainerFractionalKey | zero The zero fractional key. |
Public Functions#
| Type | Name |
|---|---|
| SBCContainerFractionalKey (char c) Constructs a fractional key from a char. |
|
| SBCContainerFractionalKey (const SBVector< 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 () noexcept Constructs an invalid fractional key. |
|
| bool | isValid () const Returns true if and only if the fractional key is valid. |
| bool | operator!= (const SBCContainerFractionalKey & other) const Inequality operator. |
| std::string | operator() () const Returns the fractional key in string format. |
| 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) Copy assignment operator. |
| SBCContainerFractionalKey & | operator= (SBCContainerFractionalKey && other) Move assignment operator. |
| bool | operator== (const SBCContainerFractionalKey & other) const 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. |
| SBCContainerFractionalKey | operator| (const SBCContainerFractionalKey & other) const Generate a key between this fractional and another fractional key. |
| virtual | ~SBCContainerFractionalKey () Destructs the fractional key. |
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
Public Static Attributes Documentation#
variable one#
The one fractional key.
variable zero#
The zero fractional key.
Public Functions Documentation#
function SBCContainerFractionalKey [1/6]#
Constructs a fractional key from a char.
Constructs a fractional key from a single character.
Parameters:
cCharacter representing the fractional key.
function SBCContainerFractionalKey [2/6]#
Constructs a fractional key from a vector of chars.
Constructs a fractional key from a vector of characters.
Parameters:
charVectorVector of characters representing the fractional key.
function SBCContainerFractionalKey [3/6]#
Constructs a fractional key from a std::string.
Constructs a fractional key from a string.
Parameters:
keyString containing the fractional key.
function SBCContainerFractionalKey [4/6]#
Copy constructor.
Copy constructs a fractional key.
Parameters:
otherFractional key to copy.
function SBCContainerFractionalKey [5/6]#
Move constructor.
Move constructs a fractional key.
Parameters:
otherFractional key to move.
function SBCContainerFractionalKey [6/6]#
Constructs an invalid fractional key.
function isValid#
Returns true if and only if the fractional key is valid.
Checks whether the fractional key is valid.
Determines if the fractional key conforms to the required format and character range.
Returns:
true if the key is a valid fractional key, false otherwise.
function operator!=#
Inequality operator.
Inequality comparison.
Parameters:
otherFractional key to compare with.
Returns:
true if the keys are not equal, false otherwise.
function operator()#
Returns the fractional key in string format.
Returns the string representation of the fractional key.
Provides the fractional key as a std::string, handling special cases for zero and one.
Returns:
The fractional key as a std::string.
function operator<#
Lexicographic comparison with another fractional key.
Lexicographic less-than comparison.
Determines if this key precedes another in lexicographic order.
Parameters:
otherFractional key to compare with.
Returns:
true if this key is less than the other key, false otherwise.
function operator<=#
Lexicographic comparison with another fractional key.
Lexicographic less-than-or-equal comparison.
Parameters:
otherFractional key to compare with.
Returns:
true if this key is less than or equal to the other key, false otherwise.
function operator=#
Copy assignment operator.
SBCContainerFractionalKey & SBCContainerFractionalKey::operator= (
const SBCContainerFractionalKey & other
)
Assigns the contents of another fractional key to this key.
Parameters:
otherFractional key to assign from.
Returns:
Reference to this fractional key.
function operator=#
Move assignment operator.
SBCContainerFractionalKey & SBCContainerFractionalKey::operator= (
SBCContainerFractionalKey && other
)
Moves the contents of another fractional key into this key.
Parameters:
otherFractional key to move from.
Returns:
Reference to this fractional key.
function operator==#
Equality operator.
Equality comparison.
Checks whether this key is equal to another.
Parameters:
otherFractional key to compare with.
Returns:
true if the keys are equal, false otherwise.
function operator>#
Lexicographic comparison with another fractional key.
Lexicographic greater-than comparison.
Determines if this key follows another in lexicographic order.
Parameters:
otherFractional key to compare with.
Returns:
true if this key is greater than the other key, false otherwise.
function operator>=#
Lexicographic comparison with another fractional key.
Lexicographic greater-than-or-equal comparison.
Parameters:
otherFractional key to compare with.
Returns:
true if this key is greater than or equal to the other key, false otherwise.
function operator|#
Generate a key between this fractional and another fractional key.
SBCContainerFractionalKey SBCContainerFractionalKey::operator| (
const SBCContainerFractionalKey & other
) const
Generates a new fractional key that lies between this key and another.
Creates a key that is lexicographically between this key and the given upper bound.
Parameters:
otherThe other fractional key to use as an upper bound.
Returns:
A new fractional key positioned between this key and the other key.
function ~SBCContainerFractionalKey#
Destructs the fractional key.
Destroys the fractional key.