rewrite of closure capturing for object literals
This commit is contained in:
@@ -26,6 +26,42 @@ namespace io {
|
||||
inline fun println(message : CharArray) { System.out?.println(message) }
|
||||
inline fun println() { System.out?.println() }
|
||||
|
||||
val ByteArray.inputStream : ByteArrayInputStream
|
||||
get() = ByteArrayInputStream(this)
|
||||
|
||||
inline fun ByteArray.inputStream(offset: Int, length: Int) : ByteArrayInputStream = ByteArrayInputStream(this, offset, length)
|
||||
|
||||
val InputStream.buffered : BufferedInputStream
|
||||
get() = if(this instanceof BufferedInputStream) this else BufferedInputStream(this)
|
||||
|
||||
inline fun InputStream.buffered(bufferSize: Int) = BufferedInputStream(this, bufferSize)
|
||||
|
||||
val InputStream.reader : InputStreamReader
|
||||
get() = InputStreamReader(this)
|
||||
|
||||
val InputStream.bufferedReader : BufferedReader
|
||||
get() = buffered.reader
|
||||
|
||||
inline fun val InputStream.reader(charset: Charset) : InputStreamReader = InputStreamReader(this, charset)
|
||||
|
||||
inline fun val InputStream.reader(charsetName: String) = InputStreamReader(this, charsetNme)
|
||||
|
||||
inline fun val InputStream.reader(charset: Charset) = InputStreamReader(this, charset)
|
||||
|
||||
inline fun val InputStream.reader(charsetDecoder: CharsetDecoder) = InputStreamReader(this, charsetDecoder)
|
||||
|
||||
fun InputStream.iterator() : ByteIterator = object: ByteIterator() {
|
||||
override val hasNext : Boolean
|
||||
get() = available() > 0
|
||||
|
||||
override fun nextByte() = read().byt
|
||||
}
|
||||
|
||||
val Reader.buffered : BufferedReader
|
||||
get() = if(this instanceof BufferedReader) this else BufferedReader(this)
|
||||
|
||||
inline fun Reader.buffered(bufferSize: Int) = BufferedReader(this, bufferSize)
|
||||
|
||||
private val stdin : BufferedReader = BufferedReader(InputStreamReader(object : InputStream() {
|
||||
override fun read() : Int {
|
||||
return System.`in`?.read() ?: -1
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
package jet;
|
||||
|
||||
import jet.typeinfo.TypeInfo;
|
||||
|
||||
/**
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public abstract class BooleanIterator implements Iterator<Boolean> {
|
||||
private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(BooleanIterator.class, false);
|
||||
|
||||
public TypeInfo getTypeInfo () {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
public final Boolean next() {
|
||||
return nextBoolean();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
package jet;
|
||||
|
||||
import jet.typeinfo.TypeInfo;
|
||||
|
||||
/**
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public abstract class ByteIterator implements Iterator<Byte> {
|
||||
private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(ByteIterator.class, false);
|
||||
|
||||
public TypeInfo getTypeInfo () {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
public final Byte next() {
|
||||
return nextByte();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
package jet;
|
||||
|
||||
import jet.typeinfo.TypeInfo;
|
||||
|
||||
/**
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public abstract class CharIterator implements Iterator<Character> {
|
||||
private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(CharIterator.class, false);
|
||||
|
||||
public TypeInfo getTypeInfo () {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
public final Character next() {
|
||||
return nextChar();
|
||||
}
|
||||
|
||||
@@ -8,10 +8,17 @@ import jet.typeinfo.TypeInfo;
|
||||
public class DefaultJetObject implements JetObject {
|
||||
private TypeInfo<?> typeInfo;
|
||||
|
||||
protected DefaultJetObject() {
|
||||
}
|
||||
|
||||
protected DefaultJetObject(TypeInfo<?> typeInfo) {
|
||||
this.typeInfo = typeInfo;
|
||||
}
|
||||
|
||||
protected final void $setTypeInfo(TypeInfo typeInfo) {
|
||||
this.typeInfo = typeInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final TypeInfo<?> getTypeInfo() {
|
||||
return typeInfo;
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
package jet;
|
||||
|
||||
import jet.typeinfo.TypeInfo;
|
||||
|
||||
/**
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public abstract class DoubleIterator implements Iterator<Double> {
|
||||
private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(DoubleIterator.class, false);
|
||||
|
||||
public TypeInfo getTypeInfo () {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
public final Double next() {
|
||||
return nextDouble();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ package jet;
|
||||
|
||||
import jet.typeinfo.TypeInfo;
|
||||
|
||||
public abstract class ExtensionFunction0<E, R> extends DefaultJetObject{
|
||||
public abstract class ExtensionFunction0<E, R> extends DefaultJetObject {
|
||||
protected ExtensionFunction0(TypeInfo<?> typeInfo) {
|
||||
super(typeInfo);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
package jet;
|
||||
|
||||
import jet.typeinfo.TypeInfo;
|
||||
|
||||
/**
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public abstract class FloatIterator implements Iterator<Float> {
|
||||
private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(FloatIterator.class, false);
|
||||
|
||||
public TypeInfo getTypeInfo () {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
public final Float next() {
|
||||
return nextFloat();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
package jet;
|
||||
|
||||
import jet.typeinfo.TypeInfo;
|
||||
|
||||
/**
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public abstract class IntIterator implements Iterator<Integer> {
|
||||
private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(IntIterator.class, false);
|
||||
|
||||
public TypeInfo getTypeInfo () {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
public final Integer next() {
|
||||
return nextInt();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
package jet;
|
||||
|
||||
import jet.typeinfo.TypeInfo;
|
||||
|
||||
/**
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public abstract class LongIterator implements Iterator<Long> {
|
||||
private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(LongIterator.class, false);
|
||||
|
||||
public TypeInfo getTypeInfo () {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
public final Long next() {
|
||||
return nextLong();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
package jet;
|
||||
|
||||
import jet.typeinfo.TypeInfo;
|
||||
|
||||
/**
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public abstract class ShortIterator implements Iterator<Short> {
|
||||
private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(ShortIterator.class, false);
|
||||
|
||||
public TypeInfo getTypeInfo () {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
public final Short next() {
|
||||
return nextShort();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user