daily pastebin goal
5%
SHARE
TWEET

[Go][excerpt] list push

cwchen Nov 21st, 2017 315 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Excerpt
  2. // Push data into the tail of the list
  3. func (list *List) Push(data interface{}) {
  4.     node := node{data: data, next: nil, prev: nil}
  5.     if list.head == nil {
  6.         list.head = &node
  7.         list.tail = &node
  8.     } else {
  9.         list.tail.next = &node
  10.         node.prev = list.tail
  11.         list.tail = &node
  12.     }
  13. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top