private void RearrangeTopN( HostEntry hostEntry ) { LinkedListNode<HostEntry> entryForTheSameHostWithPrevValue = null; var entry = this._TopNData.Last; do { if( entry.Value.Host == hostEntry.Host ) //сохраняем элемент, чтобы исключить из списка его, а не последний entryForTheSameHostWithPrevValue = entry; if( entry.Value.Hits >= hostEntry.Hits ) break; entry = entry.Previous; } while( entry != null ); this.InsertNewEntry( hostEntry, entry ); this.ShrinkList( entryForTheSameHostWithPrevValue ); }
private void InsertNewEntry( HostEntry hostEntry, LinkedListNode<HostEntry> listEntryToInsertAfter ) { if( listEntryToInsertAfter == null ) this._TopNData.AddFirst( hostEntry ); else this._TopNData.AddAfter( listEntryToInsertAfter, hostEntry ); }
protected bool Equals( HostEntry other ) { return string.Equals( this.Host, other.Host ) && this.Hits == other.Hits; }