Skip to content

Commit

Permalink
Merge branch 'main' of github.com:epfl-lara/bolts
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelchassot committed Dec 9, 2024
2 parents 2aaa7b3 + 3138763 commit b2d7c3f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions data-structures/uarray/UArrayExample.scala
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,19 @@ object UArrayExample:
end UArray

object UArray:
@extern
def ofSize[T: ClassTag](size: Int): UArray[T] = {
require(0 <= size)
@extern @ignore // used because `new Array[T]` leaks out of @extern due to some compiler magic
def _ofSize[T: ClassTag](size: Int): UArray[T] = {
@ghost val definedNot = Array.fill(size)(false)
given ct: realClassTag[T] = summon[ClassTag[T]].real
val content = new Array[T](size)
UArray[T](content, size, definedNot)
}.ensuring(res => res.size == size)
}

@extern
def ofSize[T: ClassTag](size: Int): UArray[T] = {
require(0 <= size)
_ofSize[T](size)
}.ensuring(res => res.size == size)

end UArray

Expand Down

0 comments on commit b2d7c3f

Please sign in to comment.