Skip to content

Commit

Permalink
Improved docs
Browse files Browse the repository at this point in the history
  • Loading branch information
christianrpetrin committed Nov 22, 2018
1 parent b872075 commit 712c13d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions deque.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ func (d *Deque) Init() *Deque {
// The complexity is O(1).
func (d *Deque) Len() int { return d.len }

// Front returns the first element of deque q or nil if the deque is empty.
// Front returns the first element of deque d or nil if the deque is empty.
// The second, bool result indicates whether a valid value was returned;
// if the deque is empty, false will be returned.
// if the deque is empty, false will be returned.
// The complexity is O(1).
func (d *Deque) Front() (interface{}, bool) {
if d.len == 0 {
Expand All @@ -135,9 +135,9 @@ func (d *Deque) Front() (interface{}, bool) {
return d.head.v[d.hp], true
}

// Back returns the last element of deque q or nil if the deque is empty.
// Back returns the last element of deque d or nil if the deque is empty.
// The second, bool result indicates whether a valid value was returned;
// if the deque is empty, false will be returned.
// if the deque is empty, false will be returned.
// The complexity is O(1).
func (d *Deque) Back() (interface{}, bool) {
if d.len == 0 {
Expand Down Expand Up @@ -242,7 +242,7 @@ func (d *Deque) PushBack(v interface{}) {

// PopFront retrieves and removes the current element from the front of the deque.
// The second, bool result indicates whether a valid value was returned;
// if the deque is empty, false will be returned.
// if the deque is empty, false will be returned.
// The complexity is O(1).
func (d *Deque) PopFront() (interface{}, bool) {
if d.len == 0 {
Expand Down Expand Up @@ -270,7 +270,7 @@ func (d *Deque) PopFront() (interface{}, bool) {

// PopBack retrieves and removes the current element from the back of the deque.
// The second, bool result indicates whether a valid value was returned;
// if the deque is empty, false will be returned.
// if the deque is empty, false will be returned.
// The complexity is O(1).
func (d *Deque) PopBack() (interface{}, bool) {
if d.len == 0 {
Expand Down
8 changes: 4 additions & 4 deletions doc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import (
)

func Example() {
q := deque.New()
d := deque.New()

for i := 0; i < 5; i++ {
q.PushBack(i)
d.PushBack(i)
}

for q.Len() > 0 {
v, _ := q.PopFront()
for d.Len() > 0 {
v, _ := d.PopFront()
fmt.Print(v)
}

Expand Down

0 comments on commit 712c13d

Please sign in to comment.