/** adds to the start */ public void insert(SLLNode <T> p_node) { if (m_head == null) { m_head = p_node; m_tail = p_node; return; } p_node.setNext(m_head); m_head = p_node; }
/** adds to the end */ public void push(SLLNode <T> p_node) { if (m_tail == null) { m_head = p_node; m_tail = p_node; return; } m_tail.setNext(p_node); m_tail = p_node; }
/** takes from the start */ public SLLNode <T> remove() { SLLNode <T> output = m_head; if (m_head != null) { SLLNode <T> tmp = m_head.getNext(); m_head.setNext(null); m_head = tmp; if (m_head == null) { m_tail = null; } } return(output); }