
com.github.phisgr.dds.internal.util.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dds4j Show documentation
Show all versions of dds4j Show documentation
Wrapper around the Double Dummy Solver C++ Library.
The newest version!
package com.github.phisgr.dds.internal
import com.github.phisgr.dds.Holding
import com.github.phisgr.dds.Rank
import com.github.phisgr.dds.Vulnerability
import java.lang.foreign.MemorySegment
import java.lang.foreign.ValueLayout
internal fun MemorySegment.getInt(index: Int): Int = get(ValueLayout.JAVA_INT, index * 4L)
internal fun MemorySegment.setInt(index: Int, value: Int) {
set(ValueLayout.JAVA_INT, index * 4L, value)
}
internal val MemorySegment.intSize: Int get() = Math.toIntExact(byteSize() / 4)
fun Int.toVulnerability(): Vulnerability = Vulnerability.entries[this]
fun Int.toRank(): Rank {
require(this in 2..14)
return Rank(this)
}
fun Int.toHolding(): Holding = Holding(this)
© 2015 - 2025 Weber Informatics LLC | Privacy Policy