//弹出第一个元素 public eNode <T> PopTop() { if (IsEmpty()) { Dbg.WriteLine("###eLink is empty"); return(null); } lock (elink_lock) //lock里面return也是会解锁的 { nr_entry--; eNode <T> A = next_node; next_node = next_node.next; if (next_node == null) //源sgl一个都没有了,则把last也清掉 { last_node = null; } return(A); } }
//新增一个元素到队伍尾部 public void PushTail(eNode <T> new_node) { lock (elink_lock) //lock里面return也是会解锁的 { nr_entry++; if (next_node == null) { next_node = new_node; last_node = new_node; return; } if (last_node != null) { last_node.next = new_node; last_node = new_node; return; } } Dbg.Assert(false, "###eLink is corrupt!"); }
public eNode() { this.data = default(T); this.next = null; }
/// <summary> /// 清空单链表 /// </summary> public void Clear() { next_node = null; last_node = null; nr_entry = 0; }
public eNode <T> next; //位置域,下一个结点地址 public eNode(T item) { this.data = item; this.next = null; }