Class Index<T>
An index mapping variable-sized elements to id's. The id's represent the position as if a continuous byte stream.
Inheritance
IDisposable
Index<T>
Namespace: Mars.Common.IO.Mapped.Indexes
Assembly: Mars.IO.dll
Syntax
public class Index<T> : IDisposable, ISerializableToStream, IEnumerable<KeyValuePair<long, T>>
Type Parameters
Name | Description |
---|---|
T |
Constructors
Index()
Creates a new index.
Declaration
public Index()
Index(MemoryMap, Int32)
Creates a new index.
Declaration
public Index(MemoryMap map, int accessorSize = 1024)
Parameters
Type | Name | Description |
---|---|---|
MemoryMap | map | |
System.Int32 | accessorSize |
Properties
IsReadonly
Returns true if this index is readonly.
Declaration
public bool IsReadonly { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
SizeInBytes
Returns the total size in bytes.
Declaration
public long SizeInBytes { get; }
Property Value
Type | Description |
---|---|
System.Int64 |
Methods
Add(T)
Adds a new element.
Declaration
public long Add(T element)
Parameters
Type | Name | Description |
---|---|---|
T | element |
Returns
Type | Description |
---|---|
System.Int64 |
CopyTo(Stream)
Copies this index to the given stream.
Declaration
public long CopyTo(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream |
Returns
Type | Description |
---|---|
System.Int64 |
CopyToWithSize(Stream)
Copies this index to the given stream.
Declaration
public long CopyToWithSize(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream |
Returns
Type | Description |
---|---|
System.Int64 |
CreateFromWithSize(Stream, Boolean)
Creates an index from the data in the given stream.
Declaration
public static Index<T> CreateFromWithSize(Stream stream, bool useAsMap = false)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | |
System.Boolean | useAsMap |
Returns
Type | Description |
---|---|
Index<T> |
Dispose()
Disposes all native resources associated with this index.
Declaration
public void Dispose()
Get(Int64)
Gets the element with the given id.
Declaration
public T Get(long id)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | id |
Returns
Type | Description |
---|---|
T |
GetEnumerator()
Gets the enumerator for this index.
Declaration
public IEnumerator<KeyValuePair<long, T>> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<KeyValuePair<System.Int64, T>> |
MakeWritable(MemoryMap)
Make this index writable again by injecting a new memory map.
Declaration
public void MakeWritable(MemoryMap map)
Parameters
Type | Name | Description |
---|---|---|
MemoryMap | map |
Implements
IEnumerable<>