dequeue it will be removed the first value into queue (First In First Out)
()
| 41 | |
| 42 | // dequeue it will be removed the first value into queue (First In First Out) |
| 43 | func (ll *Queue) dequeue() any { |
| 44 | if ll.isEmpty() { |
| 45 | return -1 // if is empty return -1 |
| 46 | } |
| 47 | data := ll.head.Data |
| 48 | |
| 49 | ll.head = ll.head.Next |
| 50 | |
| 51 | if ll.head == nil { |
| 52 | ll.tail = nil |
| 53 | } |
| 54 | |
| 55 | ll.length-- |
| 56 | return data |
| 57 | } |
| 58 | |
| 59 | // isEmpty it will check our list is empty or not |
| 60 | func (ll *Queue) isEmpty() bool { |