Ejemplo n.º 1
0
        public void Merge(Provider other)
        {
            foreach (var kv in other.FullPathToEntry)
            {
                var theirs = other.Entries [kv.Value];
                int index;
                if (!FullPathToEntry.TryGetValue(kv.Key, out index))
                {
                    FullPathToEntry.Add(kv.Key, CurrentId);
                    Entries.Add(CurrentId, theirs);
                    CurrentId = CurrentId + 1;
                }
                else
                {
                    var ours = Entries [index];

                    // check to see if we've removed an entry, unless we recently
                    // updated the entry:
                    long maxFreq = Math.Max(theirs.Frequency, ours.Frequency);
                    if (!theirs.IsValid && theirs.LastAccessTime >= ours.LastAccessTime)
                    {
                        maxFreq = Entry.cInvalid;
                    }
                    else if (!ours.IsValid && ours.LastAccessTime >= theirs.LastAccessTime)
                    {
                        maxFreq = Entry.cInvalid;
                    }

                    Entries [index] = new Entry(ours.FullPath, maxFreq, Math.Max(theirs.LastAccessTimeUtc, ours.LastAccessTimeUtc), ours.IsLeaf);
                }
            }
        }
Ejemplo n.º 2
0
        public void Add(Entry e)
        {
            FullPathToEntry.Add(e.FullPath.ToLower(), CurrentId);
            Entries.Add(CurrentId, e);
            string    lastElement      = GetLastElement(e.FullPath);
            string    lastElementLower = lastElement.ToLower();
            LastEntry lastEntry;

            if (!LastEntries.TryGetValue(lastElementLower, out lastEntry))
            {
                lastEntry = new LastEntry {
                    Name = lastElement, Ids = new List <int>()
                };
                LastEntries.Add(lastElementLower, lastEntry);
            }
            lastEntry.Ids.Add(CurrentId);
            CurrentId = CurrentId + 1;
        }