aboutsummaryrefslogtreecommitdiffstats
path: root/deque.go
diff options
context:
space:
mode:
authorRose Hogenson <rosehogenson@posteo.net>2025-04-11 22:47:43 -0700
committerRose Hogenson <rosehogenson@posteo.net>2025-04-11 22:47:43 -0700
commit0ae786244aeea5c66b2305459b1fd14d11c24e88 (patch)
treee51b3fe3248e4ef1daa00e8dec86aab0c2d69558 /deque.go
parentAdd a .String() method (diff)
downloaddeque-0ae786244aeea5c66b2305459b1fd14d11c24e88.tar.zst
Update documentation
Diffstat (limited to 'deque.go')
-rw-r--r--deque.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/deque.go b/deque.go
index 4eec0e6..2aa325d 100644
--- a/deque.go
+++ b/deque.go
@@ -3,9 +3,9 @@
//
// This queue has O(1) amortized inserts and removals from both ends of the
// container. It also has O(1) indexing like a vector.
-package deque
-
+//
// The core implementation is "ported" (stolen) from Rust's VecDeque.
+package deque
import (
"fmt"
@@ -42,7 +42,7 @@ func (q *Deque[T]) toPhysicalIdx(i int) int {
return q.wrapAdd(q.head, i)
}
-// At returns the item at position i.
+// At returns the item at position i. At panics if i < 0 or i >= q.Len().
func (q *Deque[T]) At(i int) T {
if !(0 <= i && i < len(q.buf)) {
panic(fmt.Sprintf("index out of range [%d] with length %d", i, len(q.buf)))