Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Yu Zhao committed Apr 4, 2019
1 parent e1a29d5 commit 10f3660
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions ch07/circular.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
type CircularLinkedList struct {
tail *Node
count int
}

type Node struct {
value int
next *Node
}

func (list *CircularLinkedList) Size() int {
return list.count
}

func (list *CircularLinkedList) IsEmpty() bool {
return list.count == 0
}

func (list * CircularLinkedList) Peek() (int, bool) {
if list.IsEmpty() {
fmt.Println("EmptyListError")
return 0, false
}
return list.tail.next.value, true
}

0 comments on commit 10f3660

Please sign in to comment.