This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Objects; | |
import java.util.Optional; | |
import java.util.StringJoiner; | |
import java.util.stream.Collector; | |
import java.util.stream.Collectors; | |
public class Singleton<T> { | |
private T value; | |
private volatile int count; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Comparator; | |
import java.util.DoubleSummaryStatistics; | |
import java.util.IntSummaryStatistics; | |
import java.util.Iterator; | |
import java.util.LongSummaryStatistics; | |
import java.util.Optional; | |
import java.util.OptionalDouble; | |
import java.util.OptionalInt; | |
import java.util.OptionalLong; | |
import java.util.PrimitiveIterator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Comparator; | |
import java.util.NoSuchElementException; | |
import java.util.Objects; | |
import java.util.Optional; | |
import java.util.function.IntPredicate; | |
public final class Range<T> { | |
private final Comparator<? super T> comparator; | |
private final Endpoint<T> min; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Grammar<T> { | |
private T last; | |
private int count; | |
private final StringJoiner joiner; | |
public Grammar() { | |
this.last = null; | |
this.count = 0; | |
this.joiner = new StringJoiner(", "); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.LinkedHashMap; | |
import java.util.LinkedList; | |
import java.util.Map; | |
import org.apache.commons.math3.geometry.euclidean.twod.Line; | |
import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; | |
import com.ibm.coderally.agent.CRSFileLog; | |
import com.ibm.coderally.agent.DefaultCarAIAgent; | |
import com.ibm.coderally.api.agent.AIUtils; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HexCharset extends Charset { | |
public static final HexCharset INSTANCE = new HexCharset(); | |
private HexCharset() { | |
super("hex", new String[0]); | |
} | |
@Override | |
public boolean contains(Charset cs) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed class Try<out T> { | |
companion object { | |
operator fun <T> invoke(f: () -> T) = try { | |
Success(f()) | |
} catch (t: Throwable) { | |
Failure(t) | |
} | |
@JvmStatic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object OneToMany { | |
private class One<O, M, C : MutableCollection<M>>(initial: O?, private val rightProperty: KMutableProperty1<O, C>) : ReadWriteProperty<M, O?> { | |
var one: O? = initial | |
override fun getValue(thisRef: M, property: KProperty<*>): O? = one | |
override fun setValue(thisRef: M, property: KProperty<*>, value: O?) { | |
when { | |
value != null -> add(value, thisRef) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.reactivex.Maybe | |
import io.reactivex.Single | |
import kotlin.properties.ReadOnlyProperty | |
import kotlin.reflect.KProperty | |
operator fun <T> Single<T>.provideDelegate(thisRef: Any?, property: KProperty<*>): ReadOnlyProperty<Any?, T> { | |
return SingleDelegate(this) | |
} | |
private class SingleDelegate<out T>(single: Single<T>) : ReadOnlyProperty<Any?, T> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.* | |
fun main(args: Array<String>) { | |
val i = DoubleMatrix.identity(4) | |
val a = DoubleMatrix.ofRows { | |
row(1.0, 2.0, 3.0, 4.0) | |
row(5.0, 6.0, 7.0, 8.0) | |
row(9.0, 10.0, 11.0, 12.0) | |
row(13.0, 14.0, 15.0, 16.0) |
OlderNewer