AceTime
1.6
Date and time classes for Arduino that support timezones from the TZ Database, and a system clock that can synchronize from an NTP server or an RTC chip.
|
Class that allows looking up the LinkEntry (LE) from its LinkRegistry (LRGB) using its linkId. More...
#include <LinkRegistrar.h>
Public Member Functions | |
LinkRegistrarTemplate (uint16_t linkRegistrySize, const LE *linkRegistry) | |
Constructor. | |
uint16_t | linkRegistrySize () const |
Return the number of (thin) links. | |
const LE * | getLinkEntryForIndex (uint16_t i) const |
Return the LinkEntry at index i. More... | |
const LE * | getLinkEntryForId (uint32_t linkId) const |
Return the LinkEntry using the linkId. More... | |
uint16_t | findIndexForId (uint32_t linkId) const |
Find the index for linkId. More... | |
Static Public Attributes | |
static const uint16_t | kInvalidIndex = 0xffff |
Invalid index to indicate error or not found. | |
Protected Member Functions | |
uint16_t | findIndexForIdLinear (uint32_t linkId) const |
Exposed only for benchmarking purposes. | |
uint16_t | findIndexForIdBinary (uint32_t linkId) const |
Exposed only for benchmarking purposes. | |
Static Protected Member Functions | |
static bool | isSorted (const LE *registry, uint16_t registrySize) |
Determine if the given link registry is sorted by id. | |
static uint16_t | linearSearchById (const LE *registry, uint16_t registrySize, uint32_t linkId) |
Find the registry index corresponding to linkId using linear search. More... | |
static uint16_t | binarySearchById (const LE *registry, uint16_t registrySize, uint32_t linkId) |
Find the registry index corresponding to linkId using a binary search. More... | |
Static Protected Attributes | |
static const uint8_t | kBinarySearchThreshold = 8 |
Use binarySearchById() if linkRegistrySize >= threshold. | |
Friends | |
class | ::LinkRegistrarTest_isSorted |
Class that allows looking up the LinkEntry (LE) from its LinkRegistry (LRGB) using its linkId.
LE | LinkEntry type (e.g. basic::LinkEntry) |
LEB | LinkEntryBroker type (e.g. basic::LinkEntryBroker) |
LRGB | LinkRegistryBroker type (e.g. basic::LinkRegistryBroker) |
Definition at line 30 of file LinkRegistrar.h.
|
inlinestaticprotected |
Find the registry index corresponding to linkId using a binary search.
Returns kInvalidIndex if not found.
The largest registrySize is UINT16_MAX so the largest valid index is UINT16_MAX - 1. This allows us to set kInvalidIndex to UINT16_MAX to indicate "Not Found".
Definition at line 130 of file LinkRegistrar.h.
|
inline |
Find the index for linkId.
Return kInvalidIndex if not found.
Definition at line 66 of file LinkRegistrar.h.
|
inline |
Return the LinkEntry using the linkId.
Return nullptr if not found.
Definition at line 56 of file LinkRegistrar.h.
|
inline |
Return the LinkEntry at index i.
Return nullptr if i is out of range.
Definition at line 49 of file LinkRegistrar.h.
|
inlinestaticprotected |
Find the registry index corresponding to linkId using linear search.
Returns kInvalidIndex if not found.
Definition at line 96 of file LinkRegistrar.h.