Class UuidOrdering

Class Documentation

class UuidOrdering

A class that represents a sequential ordering of UUIDs.

This is designed for use when marginalizing out variables, but it may have other uses.

Specifically, this class maps a UUID to a sequential index. Bidirectional access is possible. If you have a UUID, the index can be retrieved in constant time. And if you have the index, the UUID may be retrieved in constant (and fast) time. Also, iterating through the UUIDs in sequence is an efficient operation.

The UuidOrdering is not designed to be highly dynamic. UUIDs can be added, but not removed. UUIDs are assigned an index based on the order of insertion and cannot be modified.

Public Functions

UuidOrdering() = default

Default constructor.

UuidOrdering(std::initializer_list<fuse_core::UUID> uuid_list)

Construct a UuidOrdering with the provided UUIDs.

Accepts an arbitrary number of UUIDs directly. It can be called like:

UuidOrdering{uuid1, uuid2, uuid3};

Parameters:

uuid_list[in] The list of involved UUIDs

template<typename UuidConstIterator>
UuidOrdering(UuidConstIterator first, UuidConstIterator last)

Construct a UuidOrdering with the UUIDs from the provided collection.

The UuidConstIterator class must meet the ForwardIterator requirements, and when dereferenced must be compatible with a const fuse_core::UUID&.

Parameters:
  • first[in] Iterator pointing to the first UUID to add to the ordering

  • last[in] Iterator pointing to one past the last UUID to add to the ordering

bool empty() const

Returns true if there are no UUIDs in this ordering.

size_t size() const

Returns the number of UUIDs in this ordering.

This is always equal to “last index + 1”

bool exists(const unsigned int index) const

Return true if the index exists in the ordering.

bool exists(const fuse_core::UUID &uuid) const

Return true if the UUID exists in the ordering.

bool push_back(const fuse_core::UUID &uuid)

Add a new UUID to the back of the ordering.

If the UUID already exists, no change to the ordering will occur.

Parameters:

uuid[in] The UUID to insert

Returns:

True if the UUID was inserted, false if the UUID already existed

const fuse_core::UUID &operator[](const unsigned int index) const

Access the UUID stored at the provided index.

Accessing an index that does not exist results in undefined behavior

unsigned int operator[](const fuse_core::UUID &uuid)

Access the index associated with the provided UUID.

Accessing a UUID that does not exist results in the provided UUID being added to the ordering

const fuse_core::UUID &at(const unsigned int index) const

Access the UUID stored at the provided index.

If the requested index does not exist, an out_of_range exception will be thrown.

unsigned int at(const fuse_core::UUID &uuid) const

Access the index associated with the provided UUID.

If the requested UUID does not exist, an out_of_range exception will be thrown.