Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich2 committed Feb 22, 2025
1 parent 616914d commit 49925dc
Show file tree
Hide file tree
Showing 26 changed files with 40 additions and 40 deletions.
4 changes: 2 additions & 2 deletions Geom/srcLines/LinePathDblN.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ trait LinePathDblN[VT <: DblNElem] extends Any with LinePathLike[VT] with SeqSp
val res = fromArray(newArray)
var i = 0
while(i < newLen)
{ res.setElemUnsafe(i, ssIndex(i + 1))
{ res.setElemUnsafe(i, index(i + 1))
i += 1
}
res
Expand All @@ -29,7 +29,7 @@ trait LinePathDblN[VT <: DblNElem] extends Any with LinePathLike[VT] with SeqSp
val res = fromArray(newArray)
var i = 0
while(i < newLen)
{ res.setElemUnsafe(i, ssIndex(i))
{ res.setElemUnsafe(i, index(i))
i += 1
}
res
Expand Down
4 changes: 2 additions & 2 deletions Geom/srcLines/LinePathIntN.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ trait LinePathIntN[VT <: IntNElem] extends Any with LinePathLike[VT] with SeqSp
val res = fromArray(newArray)
var i = 0
while(i < newLen)
{ res.setElemUnsafe(i, ssIndex(i + 1))
{ res.setElemUnsafe(i, index(i + 1))
i += 1
}
res
Expand All @@ -29,7 +29,7 @@ trait LinePathIntN[VT <: IntNElem] extends Any with LinePathLike[VT] with SeqSp
val res = fromArray(newArray)
var i = 0
while(i < newLen)
{ res.setElemUnsafe(i, ssIndex(i))
{ res.setElemUnsafe(i, index(i))
i += 1
}
res
Expand Down
2 changes: 1 addition & 1 deletion Geom/srcPoly/Polygon.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ trait Polygon extends Any with Shape with BoundedElem with Approx[Double] with P
def unsafeNegY: Array[Double] = unsafeD2Map(d => -d)

/** Returns the vertex of the given index. Throws if the index is out of range, if it less than 1 or greater than the number of vertices. */
final def unsafeVert(rawIndex: Int): Pt2 = ssIndex(rawIndex)
final def unsafeVert(rawIndex: Int): Pt2 = index(rawIndex)

def dropVert(v: Int): Polygon =
{ val res = PolygonGen.uninitialised(numVerts - 1)
Expand Down
8 changes: 4 additions & 4 deletions Geom/srcPoly/PolygonGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ final class PolygonGen(val arrayUnsafe: Array[Double]) extends Polygon with Pt2S
/** Insert vertex. */
override def insVert(insertionPoint: Int, newVec: Pt2): PolygonGen =
{ val res = PolygonGen.uninitialised(numElems + 1)
(0 until insertionPoint).foreach(i => res.setElemUnsafe(i, ssIndex(i)))
(0 until insertionPoint).foreach(i => res.setElemUnsafe(i, index(i)))
res.setElemUnsafe(insertionPoint, newVec)
(insertionPoint until numElems).foreach(i => res.setElemUnsafe(i + 1, ssIndex(i)))
(insertionPoint until numElems).foreach(i => res.setElemUnsafe(i + 1, index(i)))
res
}

/** Insert vertices */
override def insVerts(insertionPoint: Int, newPts: Pt2 *): PolygonGen =
{ val res = PolygonGen.uninitialised(numElems + newPts.length)
(0 until insertionPoint).foreach(i => res.setElemUnsafe(i, ssIndex(i)))
(0 until insertionPoint).foreach(i => res.setElemUnsafe(i, index(i)))
newPts.iForeach((i, elem) => res.setElemUnsafe(insertionPoint + i, elem))
(insertionPoint until numElems).foreach(i => res.setElemUnsafe(i + newPts.length, ssIndex(i)))
(insertionPoint until numElems).foreach(i => res.setElemUnsafe(i + newPts.length, index(i)))
res
}

Expand Down
4 changes: 2 additions & 2 deletions Geom/srcPoly/PolygonLike.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ trait PolygonLike[VT] extends Any with VertBased[VT]
* vertex to the first vertex is the last vertex of the [[PolygonLike]]. Note the function signature (previous, vertex) => U follows the foreach based
* convention of putting the collection element 2nd or last as seen for example in fold methods'(accumulator, element) => B signature. */
def vertsPrevForEach[U](f: (VT, VT) => U): Unit = if (numVerts >= 2)
{ f(ssLast, vert(0))
{ f(last, vert(0))
var i = 2
while (i <= numVerts)
{ f(vert(i - 2), vert(i - 1))
Expand Down Expand Up @@ -61,7 +61,7 @@ trait PolygonLike[VT] extends Any with VertBased[VT]
}

/** Returns the vertex of the given index. Cycles around if the index is out of range, vert 3 retruns vert 0 on a triangle. */
def vert(index: Int): VT = ssIndex(index %% numVerts)
def vert(vertNum: Int): VT = index(vertNum %% numVerts)

/** This method should be overridden in final classes. */
def vertsForAll(f: VT => Boolean): Boolean =
Expand Down
2 changes: 1 addition & 1 deletion Geom/srcShapes/ShapeGenOld.scala
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class ShapeGenOld(val arrayUnsafe: Array[Double]) extends SeqSpecDbl7[CurveTailO
def tailForeach(fLineSeg: CurveTailOld => Unit, fArcSeg: CurveTailOld => Unit, fBezierSeg: CurveTailOld => Unit): Unit =
foreach(_.segDo(fLineSeg, fArcSeg, fBezierSeg))

@inline def segLast: CurveTailOld = ssLast
@inline def segLast: CurveTailOld = last
}

object ShapeGenOld extends CompanionSeqLikeDbl7[CurveTailOld, ShapeGenOld]
Expand Down
2 changes: 1 addition & 1 deletion Geom/srcUnits/PolygonKm3.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ final class PolygonKm3(val arrayUnsafe: Array[Double]) extends AnyVal with Polyg
* vertex) => U follows the foreach based convention of putting the collection element 2nd or last as seen for example in fold methods'
* (accumulator, element) => B signature. */
override def vertsPrevForEach[U](f: (PtKm3, PtKm3) => U): Unit = if (numVerts >= 2)
{ f(ssLast, vert(0))
{ f(last, vert(0))
var i = 2
while (i <= numVerts){
f(vert(i - 2), vert(i - 1))
Expand Down
2 changes: 1 addition & 1 deletion Geom/srcUnits/PolygonM3.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ final class PolygonM3(val arrayUnsafe: Array[Double]) extends AnyVal with Polygo
* vertex) => U follows the foreach based convention of putting the collection element 2nd or last as seen for example in fold methods'
* (accumulator, element) => B signature. */
override def vertsPrevForEach[U](f: (PtM3, PtM3) => U): Unit = if (numVerts >= 2)
{ f(ssLast, vert(0))
{ f(last, vert(0))
var i = 2
while (i <= numVerts){
f(vert(i - 2), vert(i - 1))
Expand Down
2 changes: 1 addition & 1 deletion Tiling/srcHex/HTilePolygon.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class HTilePolygon(override val arrayUnsafe: Array[Int]) extends SeqSpecInt2[HCe
override def newElem(i1: Int, i2: Int): HCen = new HCen(i1, i2)

def perimeter: PolygonHC = numElems match
{ case 1 => ssIndex(0).hVertPolygon
{ case 1 => index(0).hVertPolygon
case 2 => ???
case _ => ???
}
Expand Down
2 changes: 1 addition & 1 deletion Tiling/srcHex/PolygonHC.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class PolygonHC(val arrayUnsafe: Array[Int]) extends AnyVal with HCoordSeqSpec w
def combine(operand: PolygonHC): Option[PolygonHC] =
{
var starts: Option[(Int, Int)] = None
val a = ssIndex(0)
val a = index(0)
???
}

Expand Down
2 changes: 1 addition & 1 deletion Tiling/srcSq/PolygonSqC.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class PolygonSqC(val arrayUnsafe: Array[Int]) extends AnyVal with SqCoordSeqSpec

def combine(operand: PolygonSqC): Option[PolygonSqC] =
{ var starts: Option[(Int, Int)] = None
val a = ssIndex(0)
val a = index(0)
???
}

Expand Down
2 changes: 1 addition & 1 deletion Util/srcArr/BoolArr.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ trait BoolSeqLike extends Any with SeqLike[Boolean]

trait BoolSeqSpec extends Any with BoolSeqLike with SeqSpec[Boolean]
{ override final def numElems: Int = unsafeArray.length
override final def ssIndex(index: Int): Boolean = unsafeArray(index)
override final def index(index: Int): Boolean = unsafeArray(index)
}

/** An immutable efficient Array[Boolean] backed sequence class for [[Boolean]]s. */
Expand Down
2 changes: 1 addition & 1 deletion Util/srcArr/Dbl2Elem.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ trait SeqSpecDbl2[A <: Dbl2Elem] extends Any with SeqLikeDbl2[A] with SeqSpecDbl
def ssElem(d1: Double, d2: Double): A


override def ssIndex(index: Int): A = ssElem(arrayUnsafe(2 * index), arrayUnsafe(2 * index + 1))
override def index(index: Int): A = ssElem(arrayUnsafe(2 * index), arrayUnsafe(2 * index + 1))
override def ssElemEq(a1: A, a2: A): Boolean = (a1.dbl1 == a2.dbl1) & (a1.dbl2 == a2.dbl2)

def elem1sArray: Array[Double] =
Expand Down
2 changes: 1 addition & 1 deletion Util/srcArr/Dbl3Elem.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ trait SeqSpecDbl3[A <: Dbl3Elem] extends Any with SeqLikeDbl3[A] with SeqSpecDbl
def ssElem(d1: Double, d2: Double, d3: Double): A

override def ssElemEq(a1: A, a2: A): Boolean = (a1.dbl1 == a2.dbl1) & (a1.dbl2 == a2.dbl2) & (a1.dbl3 == a2.dbl3)
override def ssIndex(index: Int): A = ssElem(arrayUnsafe(3 * index), arrayUnsafe(3 * index + 1), arrayUnsafe(3 * index + 2))
override def index(index: Int): A = ssElem(arrayUnsafe(3 * index), arrayUnsafe(3 * index + 1), arrayUnsafe(3 * index + 2))
}

/** A specialised immutable, flat Array[Double] based sequence of a type of [[Dbl3Elem]]s. */
Expand Down
2 changes: 1 addition & 1 deletion Util/srcArr/Dbl4Elem.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ trait Dbl4SeqSpec[A <: Dbl4Elem] extends Any with SeqLikeDbl4[A] with SeqSpecDbl
def ssElem(d1: Double, d2: Double, d3: Double, d4: Double): A

override def ssElemEq(a1: A, a2: A): Boolean = (a1.dbl1 == a2.dbl1) & (a1.dbl2 == a2.dbl2) & (a1.dbl3 == a2.dbl3) & (a1.dbl4 == a2.dbl4)
override def ssIndex(index: Int): A = ssElem(arrayUnsafe(4 * index), arrayUnsafe(4 * index + 1), arrayUnsafe(4 * index + 2), arrayUnsafe(4 * index + 3))
override def index(index: Int): A = ssElem(arrayUnsafe(4 * index), arrayUnsafe(4 * index + 1), arrayUnsafe(4 * index + 2), arrayUnsafe(4 * index + 3))
}
/** A specialised immutable, flat Array[Double] based collection of a type of [[Dbl4Elem]]s. */
trait Dbl4Arr[A <: Dbl4Elem] extends Any with ArrDblN[A] with SeqLikeDbl4[A]
Expand Down
2 changes: 1 addition & 1 deletion Util/srcArr/Dbl5Elem.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ trait SeqSpecDbl5[A <: Dbl5Elem] extends Any with SeqLikeDbl5[A] with SeqSpecDbl
* sequence. */
def ssElem(d1: Double, d2: Double, d3: Double, d4: Double, d5: Double): A

def ssIndex(index: Int): A = ssElem(arrayUnsafe(5 * index), arrayUnsafe(5 * index + 1), arrayUnsafe(5 * index + 2), arrayUnsafe(5 * index + 3),
def index(index: Int): A = ssElem(arrayUnsafe(5 * index), arrayUnsafe(5 * index + 1), arrayUnsafe(5 * index + 2), arrayUnsafe(5 * index + 3),
arrayUnsafe(5 * index + 4))

override def ssElemEq(a1: A, a2: A): Boolean =
Expand Down
2 changes: 1 addition & 1 deletion Util/srcArr/Dbl6Elem.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ trait Dbl6SeqSpec[A <: Dbl6Elem] extends Any with SeqLikeDbl6[A] with SeqSpecDbl
/** Constructs an element of the specifying-sequence from 6 [[Double]]s. */
def ssElem(d1: Double, d2: Double, d3: Double, d4: Double, d5: Double, d6: Double): A

def ssIndex(index: Int): A =
def index(index: Int): A =
{ val offset = index * 6
ssElem(arrayUnsafe(offset), arrayUnsafe(offset + 1), arrayUnsafe(offset + 2), arrayUnsafe(offset + 3),
arrayUnsafe(offset + 4), arrayUnsafe(offset + 5))
Expand Down
2 changes: 1 addition & 1 deletion Util/srcArr/Dbl7Elem.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ trait SeqSpecDbl7[A <: Dbl7Elem] extends Any with SeqLikeDbl7[A] with SeqSpecDbl
def ssElemEq(a1: A, a2: A): Boolean = (a1.dbl1 == a2.dbl1) & (a1.dbl2 == a2.dbl2) & (a1.dbl3 == a2.dbl3) & (a1.dbl4 == a2.dbl4) &
(a1.dbl5 == a2.dbl5) & (a1.dbl6 == a2.dbl6) & (a1.dbl7 == a2.dbl7)

def ssIndex(index: Int): A =
def index(index: Int): A =
{ val offset = 7 * index
ssElem(arrayUnsafe(offset), arrayUnsafe(offset + 1), arrayUnsafe(offset + 2), arrayUnsafe(offset + 3), arrayUnsafe(offset + 4),
arrayUnsafe(offset + 5), arrayUnsafe(offset + 6))
Expand Down
2 changes: 1 addition & 1 deletion Util/srcArr/Int1Elem.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ trait SeqLikeInt1[A <: Int1Elem] extends Any with SeqLikeIntN[A]

/** A specialised immutable, flat Array[Int] based trait defined by a data sequence of a type of [[Int1Elem]]s. */
trait SeqSpecInt1[A <: Int1Elem] extends Any with SeqLikeInt1[A] with SeqSpecIntN[A]
{ final override def ssIndex(index: Int): A = ssElem(arrayUnsafe(index))
{ final override def index(index: Int): A = ssElem(arrayUnsafe(index))

/** Constructs an element of the specifing sequence from an [[Int]] value. */
def ssElem(intValue: Int): A
Expand Down
2 changes: 1 addition & 1 deletion Util/srcArr/Int2Elem.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ trait SeqLikeInt2[A <: Int2Elem] extends Any with SeqLikeIntN[A]

/** A specialised immutable, flat [[Array]][Int] based trait defined by a data sequence of a type of [[Int2Elem]]s. */
trait SeqSpecInt2[A <: Int2Elem] extends Any with SeqLikeInt2[A] with SeqSpecIntN[A]
{ final override def ssIndex(index: Int): A = newElem(arrayUnsafe(2 * index), arrayUnsafe(2 * index + 1))
{ final override def index(index: Int): A = newElem(arrayUnsafe(2 * index), arrayUnsafe(2 * index + 1))
final override def ssElemEq(a1: A, a2: A): Boolean = (a1.int1 == a2.int1) & (a1.int2 == a2.int2)
}

Expand Down
2 changes: 1 addition & 1 deletion Util/srcArr/Int3Elem.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ trait SeqLikeInt3[A <: Int3Elem] extends Any with SeqLikeIntN[A]

/** A specialised immutable, flat Array[Double] based trait defined by a data sequence of a type of [[Int3Elem]]s. */
trait SeqSpecInt3[A <: Int3Elem] extends Any with SeqLikeInt3[A] with SeqSpecIntN[A]
{ final override def ssIndex(index: Int): A = newElem(arrayUnsafe(3 * index), arrayUnsafe(3 * index + 1), arrayUnsafe(3 * index + 2))
{ final override def index(index: Int): A = newElem(arrayUnsafe(3 * index), arrayUnsafe(3 * index + 1), arrayUnsafe(3 * index + 2))
final override def ssElemEq(a1: A, a2: A): Boolean = (a1.int1 == a2.int1) & (a1.int2 == a2.int2) & (a1.int3 == a2.int3)
}

Expand Down
2 changes: 1 addition & 1 deletion Util/srcArr/Int4Elem.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ trait SeqSpecInt4[A <: Int4Elem] extends Any with SeqLikeInt4[A] with SeqSpecInt
{
final def ssElemEq(a1: A, a2: A): Boolean = (a1.int1 == a2.int1) & (a1.int2 == a2.int2) & (a1.int3 == a2.int3) & (a1.int4 == a2.int4)

override def ssIndex(index: Int): A =
override def index(index: Int): A =
newElem(arrayUnsafe(4 * index), arrayUnsafe(4 * index + 1), arrayUnsafe(4 * index + 2), arrayUnsafe(4 * index + 3))
}

Expand Down
2 changes: 1 addition & 1 deletion Util/srcArr/Int5Elem.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ trait SeqSpecInt5[A <: Int5Elem] extends Any with SeqLikeInt5[A] with SeqSpecInt
final def ssElemEq(a1: A, a2: A): Boolean =
(a1.int1 == a2.int1) & (a1.int2 == a2.int2) & (a1.int3 == a2.int3) & (a1.int4 == a2.int4) & (a1.int5 == a2.int5)

override def ssIndex(index: Int): A =
override def index(index: Int): A =
newElem(arrayUnsafe(5 * index), arrayUnsafe(5 * index + 1), arrayUnsafe(5 * index + 2), arrayUnsafe(5 * index + 3), arrayUnsafe(5 * index + 4))
}

Expand Down
2 changes: 1 addition & 1 deletion Util/srcArr/Int6Elem.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ trait SeqSpecInt6[A <: Int6Elem] extends Any with SeqLikeInt6[A] with SeqSpecInt
final def ssElemEq(a1: A, a2: A): Boolean =
(a1.int1 == a2.int1) & (a1.int2 == a2.int2) & (a1.int3 == a2.int3) & (a1.int4 == a2.int4) & (a1.int5 == a2.int5) & (a1.int6 == a2.int6)

override def ssIndex(index: Int): A = newElem(arrayUnsafe(6 * index), arrayUnsafe(6 * index + 1), arrayUnsafe(6 * index + 2),
override def index(index: Int): A = newElem(arrayUnsafe(6 * index), arrayUnsafe(6 * index + 1), arrayUnsafe(6 * index + 2),
arrayUnsafe(6 * index + 3), arrayUnsafe(6 * index + 4), arrayUnsafe(6 * index + 5))
}

Expand Down
18 changes: 9 additions & 9 deletions Util/srcArr/SeqSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ trait SeqSpec[+A] extends Any with SeqLike[A @uncheckedVariance]
{ type ThisT <: SeqSpec[A]

/** Accesses the specifying sequence element by a 0 based index. */
@inline def ssIndex(index: Int): A
@inline def index(index: Int): A

/** The number of data elements in the defining sequence. These collections use underlying mutable Arrays and ArrayBuffers. The length of the underlying Array
* will be a multiple of this number. */
def numElems: Int

/** Performs a side effecting function on each element of the specifying sequence in order. */
def foreach[U](f: A => U): Unit =
override def foreach[U](f: A => U): Unit =
{ var i = 0
while (i < numElems)
{ f(ssIndex(i))
{ f(index(i))
i = i + 1
}
}
Expand All @@ -27,7 +27,7 @@ trait SeqSpec[+A] extends Any with SeqLike[A @uncheckedVariance]
def tailForeach[U](f: A => U): Unit =
{ var i = 1
while (i < numElems)
{ f(ssIndex(i))
{ f(index(i))
i += 1
}
}
Expand All @@ -37,7 +37,7 @@ trait SeqSpec[+A] extends Any with SeqLike[A @uncheckedVariance]
def innerForeach[U](f: A => U): Unit =
{ var i = 1
while (i < numElems - 1)
{ f(ssIndex(i));
{ f(index(i));
i += 1
}
}
Expand All @@ -51,7 +51,7 @@ trait SeqSpec[+A] extends Any with SeqLike[A @uncheckedVariance]
def iForeach[U](f: (Int, A) => Any): Unit =
{ var i = 0
while (i < numElems)
{ f(i, ssIndex(i))
{ f(i, index(i))
i = i + 1
}
}
Expand All @@ -65,7 +65,7 @@ trait SeqSpec[+A] extends Any with SeqLike[A @uncheckedVariance]
def iForeach[U](initIndex: Int)(f: (Int, A) => U): Unit =
{ var i = 0
while (i < numElems)
{ f(i + initIndex, ssIndex(i))
{ f(i + initIndex, index(i))
i = i + 1
}
}
Expand All @@ -91,12 +91,12 @@ trait SeqSpec[+A] extends Any with SeqLike[A @uncheckedVariance]
{ var i = numElems
while (i > 0)
{ i -= 1
f(ssIndex(i))
f(index(i))
}
}

/** Last element of the specifying sequence. */
def ssLast: A = ssIndex(numElems - 1)
def last: A = index(numElems - 1)

/** FoldLeft over the tail of the specifying sequence. */
def tailFold[B](initial: B)(f: (B, A) => B) =
Expand Down
2 changes: 1 addition & 1 deletion Util/srcArr/ValueNElem.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ trait SeqSpecValueN[A <: ValueNElem] extends Any with SeqLikeValueN[A] with SeqS
{ var res = true
var i = 0
while (i < numElems & res)
{ if (!f(ssIndex(i))) res = false
{ if (!f(index(i))) res = false
i += 1
}
res
Expand Down

0 comments on commit 49925dc

Please sign in to comment.