Exemplo n.º 1
0
 internal SmallPartEnumerator(string path, IBytesGetter <T> bytesGetter, int buffer = 256)
 {
     this.elementsInBuffer = buffer;
     this.stream           = new BufferedStream(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.None));
     this.bytesGetter      = bytesGetter;
     bytesRequired         = bytesGetter != null ? bytesGetter.BytesRequired : Marshal.SizeOf(typeof(T));
     this.buffer           = new byte[bytesRequired * elementsInBuffer];
     if (bytesGetter == null)
     {
         queue = new T[elementsInBuffer];
     }
 }
Exemplo n.º 2
0
 public ExternalMemoryList(string pathToDirectory, int maxElementsInMemoryCount, IBytesGetter <T> bytesGetter = null,
                           bool sortOnSave = false)
 {
     pathToDirectory += "/";
     Directory.CreateDirectory(pathToDirectory);
     this.PathToDirectory          = pathToDirectory;
     this.MaxElementsInMemoryCount = maxElementsInMemoryCount;
     this.BytesGetter = bytesGetter;
     current          = new T[maxElementsInMemoryCount];
     bytesRequired    = BytesGetter != null ? BytesGetter.BytesRequired : Marshal.SizeOf(typeof(T));
     bytes            = new byte[maxElementsInMemoryCount * bytesRequired];
     SortOnSave       = sortOnSave;
 }