Skip to content
This repository has been archived by the owner on Jul 18, 2022. It is now read-only.

Commit

Permalink
oops
Browse files Browse the repository at this point in the history
  • Loading branch information
Foxcapades committed Jul 5, 2022
1 parent ed05584 commit 3ebef4c
Show file tree
Hide file tree
Showing 13 changed files with 222 additions and 133 deletions.
26 changes: 15 additions & 11 deletions src/main/kotlin/io/foxcapades/lib/pdk/BooleanDeque.kt
Original file line number Diff line number Diff line change
Expand Up @@ -614,30 +614,34 @@ class BooleanDeque : PrimitiveDeque<Boolean, BooleanArray> {
// backing buffer.
if (isEmpty) {
data = values.copyOf()
size = values.size
return
}

// Make sure we have enough room for the contents of the input array.
ensureCapacity(size + values.size)

// One past the current last index
val oldTail = internalIndex(size)
// New last index
val newTail = internalIndex(size + values.size)

// If the new tail is still after the old tail, then we can copy the data in
// a single array copy
if (oldTail <= newTail) {
values.copyInto(data, oldTail)
return
}
} else {

// So the new tail is before the old tail in the buffer array, we need to do
// 2 array copies: one from the current tail till the end of the buffer
// array, the next from the start of the buffer array until the new tail
// position
// So the new tail is before the old tail in the buffer array, we need to do
// 2 array copies: one from the current tail till the end of the buffer
// array, the next from the start of the buffer array until the new tail
// position

// Copy from the old tail until the end of the data buffer
values.copyInto(data, oldTail, 0, data.size - oldTail)
// Copy from the start of the data buffer
values.copyInto(data, 0, data.size - oldTail)
// Copy from the old tail until the end of the data buffer
values.copyInto(data, oldTail, 0, data.size - oldTail)
// Copy from the start of the data buffer
values.copyInto(data, 0, data.size - oldTail)
}

size += values.size
}
Expand Down Expand Up @@ -762,7 +766,7 @@ class BooleanDeque : PrimitiveDeque<Boolean, BooleanArray> {

// If the contents of the deque are in a straight line, we can just copy
// them out
if (realHead < realTail) {
if (realHead <= realTail) {
return data.copyOfRange(realHead, realTail + 1)
}

Expand Down
26 changes: 15 additions & 11 deletions src/main/kotlin/io/foxcapades/lib/pdk/ByteDeque.kt
Original file line number Diff line number Diff line change
Expand Up @@ -614,30 +614,34 @@ class ByteDeque : PrimitiveDeque<Byte, ByteArray> {
// backing buffer.
if (isEmpty) {
data = values.copyOf()
size = values.size
return
}

// Make sure we have enough room for the contents of the input array.
ensureCapacity(size + values.size)

// One past the current last index
val oldTail = internalIndex(size)
// New last index
val newTail = internalIndex(size + values.size)

// If the new tail is still after the old tail, then we can copy the data in
// a single array copy
if (oldTail <= newTail) {
values.copyInto(data, oldTail)
return
}
} else {

// So the new tail is before the old tail in the buffer array, we need to do
// 2 array copies: one from the current tail till the end of the buffer
// array, the next from the start of the buffer array until the new tail
// position
// So the new tail is before the old tail in the buffer array, we need to do
// 2 array copies: one from the current tail till the end of the buffer
// array, the next from the start of the buffer array until the new tail
// position

// Copy from the old tail until the end of the data buffer
values.copyInto(data, oldTail, 0, data.size - oldTail)
// Copy from the start of the data buffer
values.copyInto(data, 0, data.size - oldTail)
// Copy from the old tail until the end of the data buffer
values.copyInto(data, oldTail, 0, data.size - oldTail)
// Copy from the start of the data buffer
values.copyInto(data, 0, data.size - oldTail)
}

size += values.size
}
Expand Down Expand Up @@ -762,7 +766,7 @@ class ByteDeque : PrimitiveDeque<Byte, ByteArray> {

// If the contents of the deque are in a straight line, we can just copy
// them out
if (realHead < realTail) {
if (realHead <= realTail) {
return data.copyOfRange(realHead, realTail + 1)
}

Expand Down
26 changes: 15 additions & 11 deletions src/main/kotlin/io/foxcapades/lib/pdk/CharDeque.kt
Original file line number Diff line number Diff line change
Expand Up @@ -614,30 +614,34 @@ class CharDeque : PrimitiveDeque<Char, CharArray> {
// backing buffer.
if (isEmpty) {
data = values.copyOf()
size = values.size
return
}

// Make sure we have enough room for the contents of the input array.
ensureCapacity(size + values.size)

// One past the current last index
val oldTail = internalIndex(size)
// New last index
val newTail = internalIndex(size + values.size)

// If the new tail is still after the old tail, then we can copy the data in
// a single array copy
if (oldTail <= newTail) {
values.copyInto(data, oldTail)
return
}
} else {

// So the new tail is before the old tail in the buffer array, we need to do
// 2 array copies: one from the current tail till the end of the buffer
// array, the next from the start of the buffer array until the new tail
// position
// So the new tail is before the old tail in the buffer array, we need to do
// 2 array copies: one from the current tail till the end of the buffer
// array, the next from the start of the buffer array until the new tail
// position

// Copy from the old tail until the end of the data buffer
values.copyInto(data, oldTail, 0, data.size - oldTail)
// Copy from the start of the data buffer
values.copyInto(data, 0, data.size - oldTail)
// Copy from the old tail until the end of the data buffer
values.copyInto(data, oldTail, 0, data.size - oldTail)
// Copy from the start of the data buffer
values.copyInto(data, 0, data.size - oldTail)
}

size += values.size
}
Expand Down Expand Up @@ -762,7 +766,7 @@ class CharDeque : PrimitiveDeque<Char, CharArray> {

// If the contents of the deque are in a straight line, we can just copy
// them out
if (realHead < realTail) {
if (realHead <= realTail) {
return data.copyOfRange(realHead, realTail + 1)
}

Expand Down
26 changes: 15 additions & 11 deletions src/main/kotlin/io/foxcapades/lib/pdk/DoubleDeque.kt
Original file line number Diff line number Diff line change
Expand Up @@ -614,30 +614,34 @@ class DoubleDeque : PrimitiveDeque<Double, DoubleArray> {
// backing buffer.
if (isEmpty) {
data = values.copyOf()
size = values.size
return
}

// Make sure we have enough room for the contents of the input array.
ensureCapacity(size + values.size)

// One past the current last index
val oldTail = internalIndex(size)
// New last index
val newTail = internalIndex(size + values.size)

// If the new tail is still after the old tail, then we can copy the data in
// a single array copy
if (oldTail <= newTail) {
values.copyInto(data, oldTail)
return
}
} else {

// So the new tail is before the old tail in the buffer array, we need to do
// 2 array copies: one from the current tail till the end of the buffer
// array, the next from the start of the buffer array until the new tail
// position
// So the new tail is before the old tail in the buffer array, we need to do
// 2 array copies: one from the current tail till the end of the buffer
// array, the next from the start of the buffer array until the new tail
// position

// Copy from the old tail until the end of the data buffer
values.copyInto(data, oldTail, 0, data.size - oldTail)
// Copy from the start of the data buffer
values.copyInto(data, 0, data.size - oldTail)
// Copy from the old tail until the end of the data buffer
values.copyInto(data, oldTail, 0, data.size - oldTail)
// Copy from the start of the data buffer
values.copyInto(data, 0, data.size - oldTail)
}

size += values.size
}
Expand Down Expand Up @@ -762,7 +766,7 @@ class DoubleDeque : PrimitiveDeque<Double, DoubleArray> {

// If the contents of the deque are in a straight line, we can just copy
// them out
if (realHead < realTail) {
if (realHead <= realTail) {
return data.copyOfRange(realHead, realTail + 1)
}

Expand Down
26 changes: 15 additions & 11 deletions src/main/kotlin/io/foxcapades/lib/pdk/FloatDeque.kt
Original file line number Diff line number Diff line change
Expand Up @@ -614,30 +614,34 @@ class FloatDeque : PrimitiveDeque<Float, FloatArray> {
// backing buffer.
if (isEmpty) {
data = values.copyOf()
size = values.size
return
}

// Make sure we have enough room for the contents of the input array.
ensureCapacity(size + values.size)

// One past the current last index
val oldTail = internalIndex(size)
// New last index
val newTail = internalIndex(size + values.size)

// If the new tail is still after the old tail, then we can copy the data in
// a single array copy
if (oldTail <= newTail) {
values.copyInto(data, oldTail)
return
}
} else {

// So the new tail is before the old tail in the buffer array, we need to do
// 2 array copies: one from the current tail till the end of the buffer
// array, the next from the start of the buffer array until the new tail
// position
// So the new tail is before the old tail in the buffer array, we need to do
// 2 array copies: one from the current tail till the end of the buffer
// array, the next from the start of the buffer array until the new tail
// position

// Copy from the old tail until the end of the data buffer
values.copyInto(data, oldTail, 0, data.size - oldTail)
// Copy from the start of the data buffer
values.copyInto(data, 0, data.size - oldTail)
// Copy from the old tail until the end of the data buffer
values.copyInto(data, oldTail, 0, data.size - oldTail)
// Copy from the start of the data buffer
values.copyInto(data, 0, data.size - oldTail)
}

size += values.size
}
Expand Down Expand Up @@ -762,7 +766,7 @@ class FloatDeque : PrimitiveDeque<Float, FloatArray> {

// If the contents of the deque are in a straight line, we can just copy
// them out
if (realHead < realTail) {
if (realHead <= realTail) {
return data.copyOfRange(realHead, realTail + 1)
}

Expand Down
26 changes: 15 additions & 11 deletions src/main/kotlin/io/foxcapades/lib/pdk/IntDeque.kt
Original file line number Diff line number Diff line change
Expand Up @@ -614,30 +614,34 @@ class IntDeque : PrimitiveDeque<Int, IntArray> {
// backing buffer.
if (isEmpty) {
data = values.copyOf()
size = values.size
return
}

// Make sure we have enough room for the contents of the input array.
ensureCapacity(size + values.size)

// One past the current last index
val oldTail = internalIndex(size)
// New last index
val newTail = internalIndex(size + values.size)

// If the new tail is still after the old tail, then we can copy the data in
// a single array copy
if (oldTail <= newTail) {
values.copyInto(data, oldTail)
return
}
} else {

// So the new tail is before the old tail in the buffer array, we need to do
// 2 array copies: one from the current tail till the end of the buffer
// array, the next from the start of the buffer array until the new tail
// position
// So the new tail is before the old tail in the buffer array, we need to do
// 2 array copies: one from the current tail till the end of the buffer
// array, the next from the start of the buffer array until the new tail
// position

// Copy from the old tail until the end of the data buffer
values.copyInto(data, oldTail, 0, data.size - oldTail)
// Copy from the start of the data buffer
values.copyInto(data, 0, data.size - oldTail)
// Copy from the old tail until the end of the data buffer
values.copyInto(data, oldTail, 0, data.size - oldTail)
// Copy from the start of the data buffer
values.copyInto(data, 0, data.size - oldTail)
}

size += values.size
}
Expand Down Expand Up @@ -762,7 +766,7 @@ class IntDeque : PrimitiveDeque<Int, IntArray> {

// If the contents of the deque are in a straight line, we can just copy
// them out
if (realHead < realTail) {
if (realHead <= realTail) {
return data.copyOfRange(realHead, realTail + 1)
}

Expand Down
26 changes: 15 additions & 11 deletions src/main/kotlin/io/foxcapades/lib/pdk/LongDeque.kt
Original file line number Diff line number Diff line change
Expand Up @@ -614,30 +614,34 @@ class LongDeque : PrimitiveDeque<Long, LongArray> {
// backing buffer.
if (isEmpty) {
data = values.copyOf()
size = values.size
return
}

// Make sure we have enough room for the contents of the input array.
ensureCapacity(size + values.size)

// One past the current last index
val oldTail = internalIndex(size)
// New last index
val newTail = internalIndex(size + values.size)

// If the new tail is still after the old tail, then we can copy the data in
// a single array copy
if (oldTail <= newTail) {
values.copyInto(data, oldTail)
return
}
} else {

// So the new tail is before the old tail in the buffer array, we need to do
// 2 array copies: one from the current tail till the end of the buffer
// array, the next from the start of the buffer array until the new tail
// position
// So the new tail is before the old tail in the buffer array, we need to do
// 2 array copies: one from the current tail till the end of the buffer
// array, the next from the start of the buffer array until the new tail
// position

// Copy from the old tail until the end of the data buffer
values.copyInto(data, oldTail, 0, data.size - oldTail)
// Copy from the start of the data buffer
values.copyInto(data, 0, data.size - oldTail)
// Copy from the old tail until the end of the data buffer
values.copyInto(data, oldTail, 0, data.size - oldTail)
// Copy from the start of the data buffer
values.copyInto(data, 0, data.size - oldTail)
}

size += values.size
}
Expand Down Expand Up @@ -762,7 +766,7 @@ class LongDeque : PrimitiveDeque<Long, LongArray> {

// If the contents of the deque are in a straight line, we can just copy
// them out
if (realHead < realTail) {
if (realHead <= realTail) {
return data.copyOfRange(realHead, realTail + 1)
}

Expand Down
Loading

0 comments on commit 3ebef4c

Please sign in to comment.