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

Commit

Permalink
fixed error that occurs when merging single value deques
Browse files Browse the repository at this point in the history
  • Loading branch information
Foxcapades committed Jul 2, 2022
1 parent ed3d6d0 commit c6f2e8c
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/io/foxcapades/lib/pdk/BooleanDeque.kt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class BooleanDeque : PrimitiveDeque<Boolean, BooleanArray> {
internalIndex(rem - 1)

// If the desired data is in a straight line (unbroken)
if (realHead < realTail) {
if (realHead <= realTail) {
// then we can straight copy and be done
data.copyInto(array, offset, realHead, realTail+1)
return
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/foxcapades/lib/pdk/ByteDeque.kt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class ByteDeque : PrimitiveDeque<Byte, ByteArray> {
internalIndex(rem - 1)

// If the desired data is in a straight line (unbroken)
if (realHead < realTail) {
if (realHead <= realTail) {
// then we can straight copy and be done
data.copyInto(array, offset, realHead, realTail+1)
return
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/foxcapades/lib/pdk/CharDeque.kt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class CharDeque : PrimitiveDeque<Char, CharArray> {
internalIndex(rem - 1)

// If the desired data is in a straight line (unbroken)
if (realHead < realTail) {
if (realHead <= realTail) {
// then we can straight copy and be done
data.copyInto(array, offset, realHead, realTail+1)
return
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/foxcapades/lib/pdk/DoubleDeque.kt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class DoubleDeque : PrimitiveDeque<Double, DoubleArray> {
internalIndex(rem - 1)

// If the desired data is in a straight line (unbroken)
if (realHead < realTail) {
if (realHead <= realTail) {
// then we can straight copy and be done
data.copyInto(array, offset, realHead, realTail+1)
return
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/foxcapades/lib/pdk/FloatDeque.kt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class FloatDeque : PrimitiveDeque<Float, FloatArray> {
internalIndex(rem - 1)

// If the desired data is in a straight line (unbroken)
if (realHead < realTail) {
if (realHead <= realTail) {
// then we can straight copy and be done
data.copyInto(array, offset, realHead, realTail+1)
return
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/foxcapades/lib/pdk/IntDeque.kt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class IntDeque : PrimitiveDeque<Int, IntArray> {
internalIndex(rem - 1)

// If the desired data is in a straight line (unbroken)
if (realHead < realTail) {
if (realHead <= realTail) {
// then we can straight copy and be done
data.copyInto(array, offset, realHead, realTail+1)
return
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/foxcapades/lib/pdk/LongDeque.kt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class LongDeque : PrimitiveDeque<Long, LongArray> {
internalIndex(rem - 1)

// If the desired data is in a straight line (unbroken)
if (realHead < realTail) {
if (realHead <= realTail) {
// then we can straight copy and be done
data.copyInto(array, offset, realHead, realTail+1)
return
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/foxcapades/lib/pdk/ShortDeque.kt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class ShortDeque : PrimitiveDeque<Short, ShortArray> {
internalIndex(rem - 1)

// If the desired data is in a straight line (unbroken)
if (realHead < realTail) {
if (realHead <= realTail) {
// then we can straight copy and be done
data.copyInto(array, offset, realHead, realTail+1)
return
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/foxcapades/lib/pdk/UByteDeque.kt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class UByteDeque : PrimitiveDeque<UByte, UByteArray> {
internalIndex(rem - 1)

// If the desired data is in a straight line (unbroken)
if (realHead < realTail) {
if (realHead <= realTail) {
// then we can straight copy and be done
data.copyInto(array, offset, realHead, realTail+1)
return
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/foxcapades/lib/pdk/UIntDeque.kt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class UIntDeque : PrimitiveDeque<UInt, UIntArray> {
internalIndex(rem - 1)

// If the desired data is in a straight line (unbroken)
if (realHead < realTail) {
if (realHead <= realTail) {
// then we can straight copy and be done
data.copyInto(array, offset, realHead, realTail+1)
return
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/foxcapades/lib/pdk/ULongDeque.kt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class ULongDeque : PrimitiveDeque<ULong, ULongArray> {
internalIndex(rem - 1)

// If the desired data is in a straight line (unbroken)
if (realHead < realTail) {
if (realHead <= realTail) {
// then we can straight copy and be done
data.copyInto(array, offset, realHead, realTail+1)
return
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/foxcapades/lib/pdk/UShortDeque.kt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class UShortDeque : PrimitiveDeque<UShort, UShortArray> {
internalIndex(rem - 1)

// If the desired data is in a straight line (unbroken)
if (realHead < realTail) {
if (realHead <= realTail) {
// then we can straight copy and be done
data.copyInto(array, offset, realHead, realTail+1)
return
Expand Down
7 changes: 4 additions & 3 deletions src/test/kotlin/io/foxcapades/lib/pdk/ByteDequeTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,11 @@ internal class ByteDequeTest {
@Test
fun t1() {
val t1 = ByteDeque("hello".toByteArray())
val t2 = ByteDeque("world".toByteArray())
val t3 = t1 + t2
val t2 = ByteDeque(" ".toByteArray())
val t3 = ByteDeque("world".toByteArray())
val t4 = t1 + t2 + t3

assertEquals("helloworld", String(t3.toArray()))
assertEquals("hello world", String(t4.toArray()))
}
}
}

0 comments on commit c6f2e8c

Please sign in to comment.