Example #1
0
        public void construction()
        {
            // Idea:
            // We build a trie (wide, not ternary) using backward links only (as an alternative to a persistent trie)
            // This is our permanent and growable data structure.
            // We then make a separate 'forward links index' as a NON-STORED in-memory cache.
            // This cache gets invalidated on every write, and rebuilt during a read if the invalidation flag is set.
            // (ThreadStatic on cache?)
            //
            // Note: using a normal persistent trie might cause an issue, as it duplicates on prefix reuse.

            var subject = new ReverseTrie <SerialGuid>();

            var val1 = SerialGuid.Wrap(Guid.NewGuid());
            var val2 = SerialGuid.Wrap(Guid.NewGuid());
            var val3 = SerialGuid.Wrap(Guid.NewGuid());
            var val4 = SerialGuid.Wrap(Guid.NewGuid());

            subject.Add("Hello world", val1);
            subject.Add("Hello Dave", val2);
            subject.Add("Jello world", val3);
            subject.Add("Hello worldly goods", val4);

            Console.WriteLine($"\r\nResult:\r\n{subject.DiagnosticDescription()}");
        }