Esempio n. 1
0
		public LRUHashEntry()
		{
			m_key = null;
			m_data = null;
			m_next = null;
			m_LRU_prev = m_LRU_next = this;
		}
Esempio n. 2
0
		public void BreakLinks()
		{
			m_LRU_prev.m_LRU_next = m_LRU_next;
			m_LRU_next.m_LRU_prev = m_LRU_prev;

			m_LRU_prev = m_LRU_next = this;
		}
Esempio n. 3
0
		public LRUHashEntry(object key, object data)
		{
			m_key = key;
			m_data = data;
			m_next = null;
			m_LRU_prev = m_LRU_next = this;
		}
Esempio n. 4
0
        public void BreakLinks()
        {
            m_LRU_prev.m_LRU_next = m_LRU_next;
            m_LRU_next.m_LRU_prev = m_LRU_prev;

            m_LRU_prev = m_LRU_next = this;
        }
Esempio n. 5
0
 public LRUHashEntry()
 {
     m_key      = null;
     m_data     = null;
     m_next     = null;
     m_LRU_prev = m_LRU_next = this;
 }
Esempio n. 6
0
 public LRUHashEntry(object key, object data)
 {
     m_key      = key;
     m_data     = data;
     m_next     = null;
     m_LRU_prev = m_LRU_next = this;
 }
Esempio n. 7
0
		public LRUHashtable(int size, int limit)
		{
			m_size = size;
			m_items = new LRUHashEntry[size];
			m_count = 0;
			m_cache_limit = limit;
			m_LRU = new LRUHashEntry();
		}
Esempio n. 8
0
		public void BuildLinks(LRUHashEntry LRU_prev, LRUHashEntry LRU_next)
		{
			LRU_prev.m_LRU_next = this;
			LRU_next.m_LRU_prev = this;

			m_LRU_prev = LRU_prev;
			m_LRU_next = LRU_next;
		}
Esempio n. 9
0
        public void BuildLinks(LRUHashEntry LRU_prev, LRUHashEntry LRU_next)
        {
            LRU_prev.m_LRU_next = this;
            LRU_next.m_LRU_prev = this;

            m_LRU_prev = LRU_prev;
            m_LRU_next = LRU_next;
        }
Esempio n. 10
0
		public bool Insert(object key, object data)
		{
			if (m_count >= m_cache_limit)
			{
				//kick one out
				LRUHashEntry victim = m_LRU.LRU_Prev;
				bool t = Delete(victim.Key);
				Debug.Assert(t);
			}

			int pos = (int)(Math.Abs(key.GetHashCode()) % m_size);

			LRUHashEntry head = m_items[pos];

			if (head == null)
			{
				LRUHashEntry ent = new LRUHashEntry(key, data);
				m_items[pos] = ent;
				//put his into the front of the LRU list
				ent.BuildLinks(m_LRU, m_LRU.LRU_Next);
			}
			else
			{
				while (head.Next != null &&head.Key != key)
				{
					head = head.Next;
				}
				if (head.Key.Equals(key))
					throw new OOD.Exception.ProgramLogicError(this, "Insert an existing key into the hashtable");
				else
				{
					LRUHashEntry e = new  LRUHashEntry(key, data);
                    head.Next = e;
					e.BuildLinks(m_LRU, m_LRU.LRU_Next);
				}
			}

			m_count ++;
			return true;
		}
Esempio n. 11
0
			public bool MoveNext() 
			{
				if (m_current == null)
				{
					while (m_row < m_table.m_size && m_table.m_items[m_row] == null)
					{
						m_row ++;
					}
					if (m_row < m_table.m_size)
						m_current = m_table.m_items[m_row];
					else
						m_current = null;
					m_row ++;
				}
				else
				{
					if (m_current.Next != null)
						m_current = m_current.Next;
					else
					{
						while (m_row < m_table.m_size && m_table.m_items[m_row] == null)
						{
							m_row ++;
						}
						if (m_row < m_table.m_size)
							m_current = m_table.m_items[m_row];
						else
							m_current = null;
						m_row ++;
					}
				}

				return m_current != null;
			}