Rhino C++ API  8.6
Classes | Public Member Functions | List of all members
ON_SerialNumberMap Class Reference

#include <opennurbs_lookup.h>

Classes

struct  MAP_VALUE
 
struct  SN_ELEMENT
 

Public Member Functions

 ON_SerialNumberMap ()
 
 ~ON_SerialNumberMap ()
 
ON__UINT64 ActiveIdCount () const
 
ON__UINT64 ActiveSerialNumberCount () const
 
struct SN_ELEMENTAddSerialNumber (ON__UINT64 sn)
 
struct SN_ELEMENTAddSerialNumberAndId (ON__UINT64 sn, ON_UUID id)
 
void Dump (ON_TextLog &text_log) const
 
void EmptyList ()
 
struct SN_ELEMENTFindId (ON_UUID) const
 
struct SN_ELEMENTFindSerialNumber (ON__UINT64 sn) const
 
struct SN_ELEMENTFirstElement () const
 
ON__UINT64 GetElements (ON__UINT64 sn0, ON__UINT64 sn1, ON__UINT64 max_count, ON_SimpleArray< SN_ELEMENT > &elements) const
 
bool IsValid (bool bBuildHashTable, ON_TextLog *textlog) const
 
struct SN_ELEMENTLastElement () const
 
struct SN_ELEMENTRemoveId (ON__UINT64 sn, ON_UUID id)
 
struct SN_ELEMENTRemoveSerialNumberAndId (ON__UINT64 sn)
 

Detailed Description

Copyright (c) 1993-2022 Robert McNeel & Associates. All rights reserved. OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert McNeel & Associates.

THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF MERCHANTABILITY ARE HEREBY DISCLAIMED.

For complete openNURBS copyright information see http://www.opennurbs.org. Description: ON_SerialNumberMap provides a way to map set of unique serial number - uuid pairs to application defined values so that adding, finding and removing serial numbers is fast and efficient. The class is designed to handle several millions of unique serial numbers. There are no restrictions on what order numbers are added and removed. The minimum memory footprint is less than 150KB and doesn't increase until you have more than 8000 serial numbers. It is possible to have an active serial number and an inactive id.

Constructor & Destructor Documentation

◆ ON_SerialNumberMap()

ON_SerialNumberMap::ON_SerialNumberMap ( )

◆ ~ON_SerialNumberMap()

ON_SerialNumberMap::~ON_SerialNumberMap ( )

Member Function Documentation

◆ ActiveIdCount()

ON__UINT64 ON_SerialNumberMap::ActiveIdCount ( ) const

Returns: Number of active ids in the list. This number is less than or equal to ActiveSerialNumberCount().

◆ ActiveSerialNumberCount()

ON__UINT64 ON_SerialNumberMap::ActiveSerialNumberCount ( ) const

Returns: Number of active serial numbers in the list.

◆ AddSerialNumber()

struct SN_ELEMENT* ON_SerialNumberMap::AddSerialNumber ( ON__UINT64  sn)

Description: Add a serial number to the map. Parameters: sn - [in] serial number to add. Returns: If the serial number is valid (>0), a pointer to its element is returned. When a new element is added, every byte of the m_value field is set to 0. If the serial number was already active, its element is also returned. If you need to distinguish between new and previously existing elements, then set an m_value field to something besides 0 after you add a new serial number. The id associated with this serial number will be zero and cannot be found using FindId(). Restrictions: The returned pointer may become invalid after any subsequent calls to any function in this class.
If you need to save information in the returned SN_ELEMENT for future use, you must copy the information into storage you are managing.

You may change the value of the SN_ELEMENT's m_value field. You must NEVER change any other SN_ELEMENT fields or you will break searching and possibly cause crashes.

◆ AddSerialNumberAndId()

struct SN_ELEMENT* ON_SerialNumberMap::AddSerialNumberAndId ( ON__UINT64  sn,
ON_UUID  id 
)

Parameters: sn - [in] serial number to add. id - [in] suggested id to add. If id is zero or already in use, another id will be assigned to the element. Returns: If the serial number is valid (>0), a pointer to its element is returned. When a new element is added, every byte of the m_value field is set to 0. If the serial number was already active, its element is also returned. If you need to distinguish between new and previously existing elements, then set an m_value field to something besides 0 after you add a new serial number. If the id parameter is nil, then a new uuid is created and added. If the id parameter is not nil but is active on another element, a new uuid is created and added. You can inspect the value of m_id on the returned element to determine the id AddSerialNumberAndId() assigned to the element.

Restrictions: The returned pointer may become invalid after any subsequent calls to any function in this class.
If you need to save information in the returned SN_ELEMENT for future use, you must copy the information into storage you are managing.

You may change the value of the SN_ELEMENT's m_value field. You must NEVER change any other SN_ELEMENT fields or you will break searching and possibly cause crashes.

◆ Dump()

void ON_SerialNumberMap::Dump ( ON_TextLog text_log) const

◆ EmptyList()

void ON_SerialNumberMap::EmptyList ( )

Description: Empties the list.

◆ FindId()

struct SN_ELEMENT* ON_SerialNumberMap::FindId ( ON_UUID  ) const

Parameters: id - [in] id number to search for. Returns: If the id is active, a pointer to its element is returned. Restrictions: The returned pointer may become invalid after any subsequent calls to any function in this class.
If you need to save information in the returned SN_ELEMENT for future use, you must copy the information into storage you are managing.

You may change the value of the SN_ELEMENT's m_value field. You must NEVER change any other SN_ELEMENT fields or you will break searching and possibly cause crashes.

◆ FindSerialNumber()

struct SN_ELEMENT* ON_SerialNumberMap::FindSerialNumber ( ON__UINT64  sn) const

Parameters: sn - [in] serial number to search for. Returns: If the serial number is active, a pointer to its element is returned. Restrictions: The returned pointer may become invalid after any subsequent calls to any function in this class.
If you need to save information in the returned SN_ELEMENT for future use, you must copy the information into storage you are managing.

You may change the value of the SN_ELEMENT's m_value field. You must NEVER change any other SN_ELEMENT fields or you will break searching and possibly cause crashes.

◆ FirstElement()

struct SN_ELEMENT* ON_SerialNumberMap::FirstElement ( ) const

Returns: The active element with the smallest serial number, or null if the list is empty. Restrictions: The returned pointer may become invalid after any subsequent calls to any function in this class.
If you need to save information in the returned SN_ELEMENT for future use, you must copy the information into storage you are managing.

You may change the value of the SN_ELEMENT's m_value field. You must NEVER change any other SN_ELEMENT fields or you will break searching and possibly cause crashes.

◆ GetElements()

ON__UINT64 ON_SerialNumberMap::GetElements ( ON__UINT64  sn0,
ON__UINT64  sn1,
ON__UINT64  max_count,
ON_SimpleArray< SN_ELEMENT > &  elements 
) const

Description: Finds all the elements whose serial numbers are in the range sn0 <= sn <= sn1 and appends them to the elements[] array. If max_count > 0, it specifies the maximum number of elements to append. Parameters: sn0 - [in] Minimum serial number. sn1 - [in] Maximum serial number max_count - [in] If max_count > 0, this parameter specifies the maximum number of elements to append. elements - [out] Elements are appended to this array Returns: Number of elements appended to elements[] array. Remarks: When many elements are returned, GetElements() can be substantially faster than repeated calls to FindElement().

◆ IsValid()

bool ON_SerialNumberMap::IsValid ( bool  bBuildHashTable,
ON_TextLog textlog 
) const

Description: Returns true if the map is valid. Returns false if the map is not valid. If an error is found and textlog is not null, then a description of the problem is sent to textlog. Returns: true if the list if valid.

◆ LastElement()

struct SN_ELEMENT* ON_SerialNumberMap::LastElement ( ) const

Returns: The active element with the biggest serial number, or null if the list is empty. Restrictions: The returned pointer may become invalid after any subsequent calls to any function in this class.
If you need to save information in the returned SN_ELEMENT for future use, you must copy the information into storage you are managing.

You may change the value of the SN_ELEMENT's m_value field. You must NEVER change any other SN_ELEMENT fields or you will break searching and possibly cause crashes.

◆ RemoveId()

struct SN_ELEMENT* ON_SerialNumberMap::RemoveId ( ON__UINT64  sn,
ON_UUID  id 
)

Parameters: sn - [in] If > 0, this is the serial number of the element with the id. If 0, the field is ignored. id - [in] id to search for. Returns: If the id was active, it is removed and a pointer to its element is returned. The element's serial remains active. To remove both the id and serial number, use RemoveSerialNumberAndId(). Restrictions: The returned pointer may become invalid after any subsequent calls to any function in this class.
If you need to save information in the returned SN_ELEMENT for future use, you must copy the information into storage you are managing.

You may change the value of the SN_ELEMENT's m_value field. You must NEVER change any other SN_ELEMENT fields or you will break searching and possibly cause crashes.

◆ RemoveSerialNumberAndId()

struct SN_ELEMENT* ON_SerialNumberMap::RemoveSerialNumberAndId ( ON__UINT64  sn)

Parameters: sn - [in] serial number of the element to remove. Returns: If the serial number was active, it is removed and a pointer to its element is returned. If the element's id was active, the id is also removed. Restrictions: The returned pointer may become invalid after any subsequent calls to any function in this class.
If you need to save information in the returned SN_ELEMENT for future use, you must copy the information into storage you are managing.

You may change the value of the SN_ELEMENT's m_value field. You must NEVER change any other SN_ELEMENT fields or you will break searching and possibly cause crashes.