Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import scala.scalanative.native._
- object Massiv extends App {
- type BoolMassiv = Ptr[CBool]
- type BoolMatrix = Ptr[BoolMassiv]
- object BoolMatrix {
- def alloc(outerSize: CSize, innerSize: CSize): BoolMatrix = {
- val massiv = stdlib.malloc(sizeof[BoolMassiv] * outerSize).cast[BoolMatrix]
- for (outerIndex ← 0L until outerSize) {
- massiv(outerIndex) = stdlib.malloc(sizeof[CBool] * innerSize).cast[BoolMassiv]
- val innerMassiv = massiv(outerIndex)
- for (innerIndex ← 0L until innerSize) {
- innerMassiv(innerIndex) = ((outerIndex + outerIndex) % 2) == 0
- }
- }
- massiv
- }
- def print(massiv: BoolMatrix, outerSize: CSize, innerSize: CSize): Unit = {
- for (outerIndex ← 0L until outerSize; innerIndex ← 0L until innerSize) {
- val innerMassiv = massiv(outerIndex)
- val boolValue = innerMassiv(innerIndex)
- println(s"$boolValue $outerIndex/$innerIndex")
- }
- }
- }
- val massiv = BoolMatrix.alloc(1000, 4)
- BoolMatrix.print(massiv, 1000, 4)
- }
Add Comment
Please, Sign In to add comment