ezEngine  Milestone 9
ezTagSetTemplate< BlockStorageAllocator > Class Template Reference

A dynamic collection of tags featuring fast lookups. More...

#include <TagSet.h>

Classes

class  Iterator
 Allows to iterate over all tags in this set. More...
 

Public Member Functions

void Set (const ezTag &Tag)
 Adds the given tag to the set.
 
void Remove (const ezTag &Tag)
 Removes the given tag.
 
bool IsSet (const ezTag &Tag) const
 Returns true, if the given tag is in the set.
 
bool IsAnySet (const ezTagSetTemplate &OtherSet) const
 Returns true if this tag set contains any tag set in the given other tag set.
 
ezUInt32 GetNumTagsSet () const
 Returns how many tags are in this set.
 
bool IsEmpty () const
 True if the tag set never contained any tag or was cleared.
 
void Clear ()
 Removes all tags from the set.
 
void SetByName (const char *szTag)
 Adds the tag with the given name. If the tag does not exist, it will be registered.
 
void RemoveByName (const char *szTag)
 Removes the given tag. If it doesn't exist, nothing happens.
 
bool IsSetByName (const char *szTag) const
 Checks whether the named tag is part of this set. Returns false if the tag does not exist.
 
Iterator GetIterator () const
 Returns an iterator to list all tags in this set.
 
void Save (ezStreamWriter &stream) const
 Writes the tag set state to a stream. More...
 
void Load (ezStreamReader &stream, const ezTagRegistry &registry)
 Reads the tag set state from a stream. More...
 

Friends

class Iterator
 

Detailed Description

template<typename BlockStorageAllocator = ezDefaultAllocatorWrapper>
class ezTagSetTemplate< BlockStorageAllocator >

A dynamic collection of tags featuring fast lookups.

This class can be used to store a (dynamic) collection of tags. Tags are registered within the global tag registry and allocated a bit index. The tag set allows comparatively fast lookups to check if a given tag is in the set or not. Adding a tag may have some overhead depending whether the block storage for the tag bit indices needs to be expanded or not (if the storage needs to be expanded the hybrid array will be resized). Typical storage requirements for a given tag set instance should be small since the block storage is a sliding window. The standard class which can be used is ezTagSet, usage of ezTagSetTemplate is only necessary if the allocator needs to be overridden.

Member Function Documentation

◆ Load()

template<typename BlockStorageAllocator >
void ezTagSetTemplate< BlockStorageAllocator >::Load ( ezStreamReader stream,
const ezTagRegistry registry 
)

Reads the tag set state from a stream.

Note
This will restore all tags that could be found in the given registry. The registry must be serialized separately. Tags that are not found in the registry will be ignored.

◆ Save()

template<typename BlockStorageAllocator >
void ezTagSetTemplate< BlockStorageAllocator >::Save ( ezStreamWriter stream) const

Writes the tag set state to a stream.

Note
This only stores the tag hashes. The ezTagRegistry must be stored as well, to be able to restore the tags.

The documentation for this class was generated from the following files: