daily pastebin goal
64%
SHARE
TWEET

[Go][excerpt] list push

cwchen Nov 21st, 2017 143 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
Top