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
System.Object
Index<T>
Implements
System.IDisposable
System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.Int64, T>>
System.Collections.IEnumerable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Mars.Common.IO.Mapped.Indexes
Assembly: Mars.IO.dll
Syntax
public class Index<T> : IDisposable, ISerializableToStream, IEnumerable<KeyValuePair<long, T>>, IEnumerable
Type Parameters
Name | Description |
---|---|
T |
Constructors
| Improve this Doc View SourceIndex()
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
| Improve this Doc View SourceIsReadonly
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
| Improve this Doc View SourceAdd(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 |
---|---|---|
System.IO.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 |
---|---|---|
System.IO.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 |
---|---|---|
System.IO.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 |
---|---|
System.Collections.Generic.IEnumerator<System.Collections.Generic.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 |
Explicit Interface Implementations
| Improve this Doc View SourceIEnumerable.GetEnumerator()
An index mapping variable-sized elements to id's. The id's represent the position as if a continuous byte stream.
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator |
Implements
System.IDisposable
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable