示例#1
0
            public object Clone()
            {
                InstantaneousIndex <T> clone = new InstantaneousIndex <T>();

                clone._activitesList.AddRange(this._activitesList.GetRange(0, _activitesList.Count));
                return(clone);
            }
示例#2
0
            public bool MoveNext()
            {
                do
                {
                    if (_subIndexEnumerator == null)
                    {
                        if (_enumerator.MoveNext())
                        {
                            InstantaneousIndex <T> indexEntry = _enumerator.Current;
                            _subIndexEnumerator = indexEntry.GetEnumerator();
                        }
                    }

                    if (_subIndexEnumerator != null)
                    {
                        if (_subIndexEnumerator.MoveNext())
                        {
                            _current = _subIndexEnumerator.Current;
                            return(true);
                        }
                        else
                        {
                            _subIndexEnumerator = null;
                        }
                    }
                    else
                    {
                        return(false);
                    }
                } while (true);
            }
示例#3
0
            public override bool Equals(object obj)
            {
                InstantaneousIndex <T> other = obj as InstantaneousIndex <T>;

                if (other != null && other.ClockTime == this.ClockTime)
                {
                    return(true);
                }

                return(false);
            }
示例#4
0
        public bool AddToIndex(T indexValue)
        {
            lock (this)
            {
                long currentTime = Clock.CurrentTimeInSeconds;
                long entryId     = _entryIdSequence++;
                InstantaneousIndex <T> indexEntry = null;

                if (_mainIndex.Count == 0)
                {
                    indexEntry = new InstantaneousIndex <T>();
                    indexEntry.EnableDuplicationCheck = _checkDuplication;
                    indexEntry.ClockTime = currentTime;
                    _mainIndex.Add(indexEntry);
                }
                else
                {
                    if (_checkDuplication && CheckForDuplication(indexValue))
                    {
                        return(false);
                    }

                    ExpireOldEnteries(currentTime);

                    InstantaneousIndex <T> matchEntry = null;
                    foreach (InstantaneousIndex <T> entry in _mainIndex)
                    {
                        if (entry.ClockTime == currentTime)
                        {
                            matchEntry = entry;
                            break;
                        }
                    }

                    bool newEntry = false;
                    if (matchEntry != null)
                    {
                        indexEntry = matchEntry;
                    }
                    else
                    {
                        newEntry   = true;
                        indexEntry = new InstantaneousIndex <T>();
                        indexEntry.EnableDuplicationCheck = _checkDuplication;
                        indexEntry.ClockTime = currentTime;
                        _mainIndex.Add(indexEntry);
                    }
                }
                indexEntry.AddEntry(entryId, indexValue);
            }
            return(true);
        }
示例#5
0
        public bool AddToIndex(T indexValue)
        {
            lock (this)
            {
                long currentTime = Clock.CurrentTimeInSeconds;
                long entryId     = _entryIdSequence++;
                InstantaneousIndex <T> indexEntry = null;

                if (_mainIndex.Count == 0)
                {
                    indexEntry = new InstantaneousIndex <T>();
                    indexEntry.EnableDuplicationCheck = _checkDuplication;
                    indexEntry.ClockTime = currentTime;
                    _mainIndex.Add(indexEntry);
                }
                else
                {
                    if (_checkDuplication && CheckForDuplication(indexValue))
                    {
                        return(false);
                    }

                    ExpireOldEnteries(currentTime);

                    // InstantaneousIndex<T> matchEntry = _mainIndex.Find(f => f.ClockTime == currentTime);
                    InstantaneousIndex <T> matchEntry = null;
                    foreach (InstantaneousIndex <T> entry in _mainIndex)
                    {
                        if (entry.ClockTime == currentTime)
                        {
                            matchEntry = entry;
                            break;
                        }
                    }

                    bool newEntry = false;
                    if (matchEntry != null)
                    {
                        indexEntry = matchEntry;
                    }
                    else
                    {
                        newEntry   = true;
                        indexEntry = new InstantaneousIndex <T>();
                        indexEntry.EnableDuplicationCheck = _checkDuplication;
                        indexEntry.ClockTime = currentTime;
                        _mainIndex.Add(indexEntry);
                    }

                    // Console.WriteLine("NoteActivity->" + "Method-overlaod:" + activity.MethodOverloadNumber +  " Clock-Time :" + currentTime + " is_new_entry :" + newEntry + " activities_count:" + _activityIndex.Count);
                    # region test
                    //if (_activityIndex.Count >= 1)
                    //{
                    //    ActivityIndexEntry matchEntry = _activityIndex[_activityIndex.Count - 1];

                    //    if (matchEntry.ClockTime == currentTime)
                    //    {
                    //        indexEntry = matchEntry;
                    //    }
                    //    else
                    //    {
                    //        indexEntry = new ActivityIndexEntry();
                    //        indexEntry.ClockTime = currentTime;
                    //        _activityIndex.Add(indexEntry);
                    //    }
                    //}
                    #endregion
                }
                indexEntry.AddEntry(entryId, indexValue);
            }
            return(true);
        }