aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--deque.go11
-rw-r--r--deque_test.go26
2 files changed, 0 insertions, 37 deletions
diff --git a/deque.go b/deque.go
index d4ef4be..3afb8a8 100644
--- a/deque.go
+++ b/deque.go
@@ -106,17 +106,6 @@ func (q *Deque[T]) Reset() {
q.buf = q.buf[:0]
}
-// AvailableBuffer returns an empty slice with q.Cap()-q.Len() capacity. This
-// slice is intended to be appended to and passed to an immediately succeeding
-// Deque.PushBack call. The slice is only valid until the next push operation on q.
-func (q *Deque[T]) AvailableBuffer() []T {
- endIdx := q.toPhysicalIdx(len(q.buf))
- if endIdx <= q.head {
- return q.buf[endIdx:endIdx:q.head]
- }
- return q.buf[endIdx:endIdx]
-}
-
// Grow makes space for at least n more elements to be inserted in the given
// deque without reallocation.
func (q *Deque[T]) Grow(n int) {
diff --git a/deque_test.go b/deque_test.go
index fede96b..d3ea63c 100644
--- a/deque_test.go
+++ b/deque_test.go
@@ -1,8 +1,6 @@
package deque
import (
- "bytes"
- "fmt"
"slices"
"testing"
)
@@ -287,27 +285,3 @@ func TestPopAll(t *testing.T) {
})
}
}
-
-func TestAvailableBuffer(t *testing.T) {
- t.Parallel()
-
- const cap = 10
- q := WithCapacity[byte](cap)
- q.PushBack(append(q.AvailableBuffer(), []byte(" ")...)...)
- q.PushBack(fmt.Appendf(q.AvailableBuffer(), "%d", 12345)...)
- for range 5 {
- q.PopFront()
- }
- q.PushBack(fmt.Appendf(q.AvailableBuffer(), "%d", 67890)...)
- if got, want := q.Cap(), cap; got != want {
- t.Errorf("Cap() = %d, want %d", got, want)
- }
- got := make([]byte, q.Len())
- for i, x := range q.All() {
- got[i] = x
- }
- want := []byte("1234567890")
- if !bytes.Equal(got, want) {
- t.Errorf("Incorrect content after appending to AvailableBuffer, got %d want %d", got, want)
- }
-}