Class BinaryFileStorage<T>
A raw data storage
public class BinaryFileStorage<T> : IEnumerable<T>, IEnumerable where T : struct
Type Parameters
T
The type of elements in the storage
- Inheritance
-
BinaryFileStorage<T>
- Implements
-
IEnumerable<T>
- Inherited Members
Constructors
BinaryFileStorage(string)
Create a binary File Storage
public BinaryFileStorage(string fileName)
Parameters
fileName
stringThe file name of the storage
BinaryFileStorage(string, IEnumerable<T>)
Create a binary File Storage with the specific data
public BinaryFileStorage(string fileName, IEnumerable<T> samples)
Parameters
fileName
stringThe file name of the storage, all data in the existing file will be replaced
samples
IEnumerable<T>The data which will be stored in the storage
BinaryFileStorage(string, int)
Create a binary File Storage
public BinaryFileStorage(string fileName, int trunkSize)
Parameters
fileName
stringThe file name of the storage
trunkSize
intThe data will be read in trunk of this size internally. Can be use to seed up the file read. A good number will be 4096
Fields
_fileInfo
The file info
protected FileInfo _fileInfo
Field Value
Properties
FileName
The file name of the storage
public string FileName { get; }
Property Value
Methods
Append(IEnumerable<T>)
Append the samples to the end of the storage
public void Append(IEnumerable<T> samples)
Parameters
samples
IEnumerable<T>The samples to be appended to the storage
Clear()
Delete all data in the existing storage, if there is any.
public void Clear()
EstimateSize()
Estimate the number of elements in this storage as the size of the storage divided by the size of the elements
public int EstimateSize()
Returns
- int
An estimation of the number of elements in this storage
GetEnumerator()
Get the data in this storage
public IEnumerator<T> GetEnumerator()
Returns
- IEnumerator<T>
The data in this storage
GetSubsamples(int)
Get the sub-sampled data in this storage
public IEnumerable<T> GetSubsamples(int subsampleRate)
Parameters
subsampleRate
intThe sub-sample rate
Returns
- IEnumerable<T>
The sub-sampled data in this storage
Peek()
Get a copy of the first element in the storage. If the storage is empty, a default value will be returned
public T Peek()
Returns
- T
A copy of the first element in the storage. If the storage is empty, a default value will be returned