using ln.collections; using System; using System.Collections.Generic; using System.Text; namespace ln.objects.index { class SimpleIndex : Index { BTreeValueSet index = new BTreeValueSet(); BTree reverseIndex = new BTree(); public SimpleIndex() { } public override void Clear() { index.Clear(); reverseIndex.Clear(); } public override void Match(Func criterion, ISet matches) { foreach (T ivalue in index.Keys) { if (criterion(ivalue)) matches.UnionWith(index[ivalue]); } } public override void Reindex(Guid uid, object value) { Remove(uid); index.Add((T)value, uid); } public override void Remove(Guid uid) { if (reverseIndex.ContainsKey(uid)) { index.TryRemove(reverseIndex[uid], uid); reverseIndex.TryRemove(uid); } } public override bool TryDeserializeIndex(byte[] serializedIndex) { throw new NotImplementedException(); } public override bool TrySerializeIndex(out byte[] serializedIndex) { throw new NotImplementedException(); } } }