public override bool Open() { _stream = new FileStream(_fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None, 64); _rbTree = new RedBlackTree(); _reader = new BinaryReader(_stream); _writer = new BinaryWriter(_stream); _count = 0; _cache = new ObjectCache(CACHE_SIZE); _cache.ObjectRemoved += new ObjectCacheEventHandler(_cache_ObjectRemoved); freePages.Clear(); int numPages = (int)(_stream.Length / PAGE_SIZE); //Tracer._Trace( "####################### " + _fileName ); for (int i = 0; i < numPages; i++) { long pageOffset = i * PAGE_SIZE; _stream.Position = pageOffset; int count = _reader.ReadInt32(); //Tracer._Trace( "####################### count = " + count.ToString() ); _stream.Position = pageOffset + HEADER_SIZE; IFixedLengthKey key = _factoryKey.FactoryMethod(_reader); int offset = _reader.ReadInt32(); if (count != 0) { _rbTree.RB_Insert(new BTreeNode(key, offset, pageOffset, count)); } else { freePages.Push(pageOffset); } _count += count; } return(true); }
internal PriorityQueueEnumerator(RedBlackTree tree) { _tree = tree; Reset(); }
public PriorityQueue() { _tree = new RedBlackTree(new QueueEntryComparer()); }