Class RefCountVector
RefCountedVector is used to keep track of which indices in a linear index list are in use/referenced.
A free list is tracked so that unreferenced indices can be re-used.
The enumerator iterates over valid indices (ie where refcount > 0)
refcounts are shorts so the maximum count is 65536.
No overflow checking is done in release builds.
Inheritance
RefCountVector
Namespace: g3
Assembly: cs.temp.dll.dll
Syntax
public class RefCountVector : IEnumerable
Constructors
RefCountVector()
Declaration
RefCountVector(RefCountVector)
Declaration
public RefCountVector(RefCountVector copy)
Parameters
RefCountVector(Int16[], Boolean)
Declaration
public RefCountVector(short[] raw_ref_counts, bool build_free_list = false)
Parameters
Type |
Name |
Description |
Int16[] |
raw_ref_counts |
|
Boolean |
build_free_list |
|
Fields
invalid
Declaration
public static readonly short invalid
Field Value
Properties
count
Declaration
public int count { get; }
Property Value
empty
Declaration
public bool empty { get; }
Property Value
is_dense
Declaration
public bool is_dense { get; }
Property Value
max_index
Declaration
public int max_index { get; }
Property Value
RawRefCounts
Declaration
public DVector<short> RawRefCounts { get; }
Property Value
UsageStats
Declaration
public string UsageStats { get; }
Property Value
Methods
allocate()
Declaration
Returns
allocate_at(Int32)
allocate at specific index, which must either be larger than current max index,
or on the free list. If larger, all elements up to this one will be pushed onto
free list. otherwise we have to do a linear search through free list.
If you are doing many of these, it is likely faster to use
allocate_at_unsafe(), and then rebuild_free_list() after you are done.
Declaration
public bool allocate_at(int index)
Parameters
Type |
Name |
Description |
Int32 |
index |
|
Returns
allocate_at_unsafe(Int32)
allocate at specific index, which must be free or larger than current max index.
However, we do not update free list. So, you probably need to do
rebuild_free_list() after calling this.
Declaration
public bool allocate_at_unsafe(int index)
Parameters
Type |
Name |
Description |
Int32 |
index |
|
Returns
debug_print()
Declaration
public string debug_print()
Returns
decrement(Int32, Int16)
Declaration
public void decrement(int index, short decrement = 1)
Parameters
GetEnumerator()
Declaration
public IEnumerator GetEnumerator()
Returns
increment(Int32, Int16)
Declaration
public int increment(int index, short increment = 1)
Parameters
Returns
isValid(Int32)
Declaration
public bool isValid(int index)
Parameters
Type |
Name |
Description |
Int32 |
index |
|
Returns
isValidUnsafe(Int32)
Declaration
public bool isValidUnsafe(int index)
Parameters
Type |
Name |
Description |
Int32 |
index |
|
Returns
rawRefCount(Int32)
Declaration
public int rawRefCount(int index)
Parameters
Type |
Name |
Description |
Int32 |
index |
|
Returns
rebuild_free_list()
Declaration
public void rebuild_free_list()
refCount(Int32)
Declaration
public int refCount(int index)
Parameters
Type |
Name |
Description |
Int32 |
index |
|
Returns
set_Unsafe(Int32, Int16)
Declaration
public void set_Unsafe(int index, short count)
Parameters
trim(Int32)
Declaration
public void trim(int maxIndex)
Parameters
Type |
Name |
Description |
Int32 |
maxIndex |
|
Implements