using System; using System.Collections.Generic; using System.Text; namespace ln.objects.index { public class IndexLeaf { public Type LeafType { get; set; } public string LeafName { get; set; } public Index Index { get; set; } Dictionary leafs = new Dictionary(); Func leafGetter; public IndexLeaf() { } public IndexLeaf(Type valueType, string leafName, Func getter) { LeafType = valueType; LeafName = leafName; leafGetter = getter; } public IndexLeaf GetLeaf(string path) => leafs[path]; public void AddLeaf(IndexLeaf indexLeaf) => leafs.Add(indexLeaf.LeafName, indexLeaf); public void RemoveLeaf(string leafName) => leafs.Remove(leafName); public void Reindex(Guid uid, object value) { Index?.Reindex(uid, value); foreach (IndexLeaf indexLeaf in leafs.Values) indexLeaf.Reindex(uid, indexLeaf.leafGetter(value)); } public void Remove(Guid uid) { Index?.Remove(uid); foreach (IndexLeaf indexLeaf in leafs.Values) indexLeaf.Remove(uid); } public void Clear() { Index?.Clear(); foreach (IndexLeaf indexLeaf in leafs.Values) indexLeaf.Clear(); } public void Match(Func criterion, ISet matches) => Index?.Match(criterion, matches); } }