Web Analytics Made Easy - Statcounter
Skip to content

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.

SBCContainerFractionalKey const SBCContainerFractionalKey::one;


variable zero#

The zero fractional key.

SBCContainerFractionalKey const SBCContainerFractionalKey::zero;


Public Functions Documentation#

function SBCContainerFractionalKey [1/6]#

Constructs a fractional key from a char.

SBCContainerFractionalKey::SBCContainerFractionalKey (
    char c
) 

Constructs a fractional key from a single character.

Parameters:

  • c Character representing the fractional key.

function SBCContainerFractionalKey [2/6]#

Constructs a fractional key from a vector of chars.

SBCContainerFractionalKey::SBCContainerFractionalKey (
    const SBVector< char > & charVector
) 

Constructs a fractional key from a vector of characters.

Parameters:

  • charVector Vector of characters representing the fractional key.

function SBCContainerFractionalKey [3/6]#

Constructs a fractional key from a std::string.

SBCContainerFractionalKey::SBCContainerFractionalKey (
    const std::string & key
) 

Constructs a fractional key from a string.

Parameters:

  • key String containing the fractional key.

function SBCContainerFractionalKey [4/6]#

Copy constructor.

SBCContainerFractionalKey::SBCContainerFractionalKey (
    const SBCContainerFractionalKey & other
) 

Copy constructs a fractional key.

Parameters:

  • other Fractional key to copy.

function SBCContainerFractionalKey [5/6]#

Move constructor.

SBCContainerFractionalKey::SBCContainerFractionalKey (
    SBCContainerFractionalKey && other
) 

Move constructs a fractional key.

Parameters:

  • other Fractional key to move.

function SBCContainerFractionalKey [6/6]#

Constructs an invalid fractional key.

SBCContainerFractionalKey::SBCContainerFractionalKey () noexcept


function isValid#

Returns true if and only if the fractional key is valid.

bool SBCContainerFractionalKey::isValid () const

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.

bool SBCContainerFractionalKey::operator!= (
    const SBCContainerFractionalKey & other
) const

Inequality comparison.

Parameters:

  • other Fractional key to compare with.

Returns:

true if the keys are not equal, false otherwise.


function operator()#

Returns the fractional key in string format.

std::string SBCContainerFractionalKey::operator() () const

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.

bool SBCContainerFractionalKey::operator< (
    const SBCContainerFractionalKey & other
) const

Lexicographic less-than comparison.

Determines if this key precedes another in lexicographic order.

Parameters:

  • other Fractional 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.

bool SBCContainerFractionalKey::operator<= (
    const SBCContainerFractionalKey & other
) const

Lexicographic less-than-or-equal comparison.

Parameters:

  • other Fractional 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:

  • other Fractional 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:

  • other Fractional key to move from.

Returns:

Reference to this fractional key.


function operator==#

Equality operator.

bool SBCContainerFractionalKey::operator== (
    const SBCContainerFractionalKey & other
) const

Equality comparison.

Checks whether this key is equal to another.

Parameters:

  • other Fractional key to compare with.

Returns:

true if the keys are equal, false otherwise.


function operator>#

Lexicographic comparison with another fractional key.

bool SBCContainerFractionalKey::operator> (
    const SBCContainerFractionalKey & other
) const

Lexicographic greater-than comparison.

Determines if this key follows another in lexicographic order.

Parameters:

  • other Fractional 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.

bool SBCContainerFractionalKey::operator>= (
    const SBCContainerFractionalKey & other
) const

Lexicographic greater-than-or-equal comparison.

Parameters:

  • other Fractional 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:

  • other The 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.

virtual SBCContainerFractionalKey::~SBCContainerFractionalKey () 

Destroys the fractional key.