Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
edwingeng committed Jul 25, 2022
1 parent d19f286 commit e1722dd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
16 changes: 8 additions & 8 deletions v2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,19 @@ func (dq *Deque[T]) PopFront() T
func (dq *Deque[T]) TryPopBack() (_ T, ok bool)
TryPopBack tries to remove a value from the back of dq and returns the
removed value and true if dq is not empty, otherwise it returns false.
removed value if any. The return value ok indicates whether it succeeded.
func (dq *Deque[T]) TryPopFront() (_ T, ok bool)
TryPopFront tries to remove a value from the front of dq and returns the
removed value and true if dq is not empty, otherwise it returns false.
removed value if any. The return value ok indicates whether it succeeded.
func (dq *Deque[T]) Back() (_ T, ok bool)
Back returns the last value of dq and true if dq is not empty, otherwise it
returns false.
Back returns the last value of dq if any. The return value ok indicates
whether it succeeded.
func (dq *Deque[T]) Front() (_ T, ok bool)
Front returns the first value of dq and true if dq is not empty, otherwise
it returns false.
Front returns the first value of dq if any. The return value ok indicates
whether it succeeded.
func (dq *Deque[T]) IsEmpty() bool
IsEmpty returns whether dq is empty.
Expand Down Expand Up @@ -112,10 +112,10 @@ func (dq *Deque[T]) Range(f func(i int, v T) bool)
Range iterates all the values in dq.
func (dq *Deque[T]) Peek(idx int) T
Peek returns the value at idx.
Peek returns the value at idx. It panics if idx is out of range.
func (dq *Deque[T]) Replace(idx int, v T)
Replace replaces the value at idx.
Replace replaces the value at idx. It panics if idx is out of range.
func (dq *Deque[T]) Dump() []T
Dump returns all the values in dq.
Expand Down
18 changes: 9 additions & 9 deletions v2/deque.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ func (dq *Deque[T]) PushFront(v T) {
c.data[c.s] = v
}

// TryPopBack tries to remove a value from the back of dq and returns the removed value
// and true if dq is not empty, otherwise it returns false.
// TryPopBack tries to remove a value from the back of dq and returns the removed value if any.
// The return value ok indicates whether it succeeded.
func (dq *Deque[T]) TryPopBack() (_ T, ok bool) {
n := len(dq.chunks)
if n == 0 {
Expand Down Expand Up @@ -235,7 +235,7 @@ func (dq *Deque[T]) PopBack() T {
}

// TryPopFront tries to remove a value from the front of dq and returns the removed value
// and true if dq is not empty, otherwise it returns false.
// if any. The return value ok indicates whether it succeeded.
func (dq *Deque[T]) TryPopFront() (_ T, ok bool) {
n := len(dq.chunks)
if n == 0 {
Expand Down Expand Up @@ -319,8 +319,8 @@ func (dq *Deque[T]) DequeueManyWithBuffer(max int, buf []T) []T {
return buf
}

// Back returns the last value of dq
// and true if dq is not empty, otherwise it returns false.
// Back returns the last value of dq if any. The return value ok
// indicates whether it succeeded.
func (dq *Deque[T]) Back() (_ T, ok bool) {
n := len(dq.chunks)
if n == 0 {
Expand All @@ -329,8 +329,8 @@ func (dq *Deque[T]) Back() (_ T, ok bool) {
return dq.chunks[n-1].back()
}

// Front returns the first value of dq
// and true if dq is not empty, otherwise it returns false.
// Front returns the first value of dq if any. The return value ok
// indicates whether it succeeded.
func (dq *Deque[T]) Front() (_ T, ok bool) {
n := len(dq.chunks)
if n == 0 {
Expand Down Expand Up @@ -405,7 +405,7 @@ func (dq *Deque[T]) Range(f func(i int, v T) bool) {
}
}

// Peek returns the value at idx.
// Peek returns the value at idx. It panics if idx is out of range.
func (dq *Deque[T]) Peek(idx int) T {
i := idx
for _, c := range dq.chunks {
Expand All @@ -421,7 +421,7 @@ func (dq *Deque[T]) Peek(idx int) T {
panic(fmt.Errorf("out of range: %d", idx))
}

// Replace replaces the value at idx.
// Replace replaces the value at idx. It panics if idx is out of range.
func (dq *Deque[T]) Replace(idx int, v T) {
i := idx
for _, c := range dq.chunks {
Expand Down

0 comments on commit e1722dd

Please sign in to comment.