本文整理汇总了Java中clojure.lang.IPersistentVector类的典型用法代码示例。如果您正苦于以下问题:Java IPersistentVector类的具体用法?Java IPersistentVector怎么用?Java IPersistentVector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IPersistentVector类属于clojure.lang包,在下文中一共展示了IPersistentVector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: done
import clojure.lang.IPersistentVector; //导入依赖的package包/类
@Override
// TODO: turns vector into sequence for type inference
public IList done() {
IPersistentVector resultVector = (IPersistentVector) xs.persistent();
Type resultType = List.lub(resultVector.seq());
return new Vector(resultType, resultVector);
}
示例2: done
import clojure.lang.IPersistentVector; //导入依赖的package包/类
public IList done(){
if (constructedList == null) {
ITransientCollection ret = PersistentVector.EMPTY.asTransient();
for(Object item : data)
ret = ret.conj(item);
IPersistentVector persistentData = (IPersistentVector) ret.persistent();
constructedList = new Vector(elementType, persistentData);
}
return constructedList;
}
示例3: insert
import clojure.lang.IPersistentVector; //导入依赖的package包/类
@Override
public IList insert(IValue newItem) {
ITransientVector result = PersistentVector.EMPTY.asTransient();
result = (ITransientVector) result.conj(newItem);
for(Object item : (Iterable<?>) xs)
result = (ITransientVector) result.conj(item);
return new Vector(this.lub(newItem), (IPersistentVector) result.persistent());
}
示例4: delete
import clojure.lang.IPersistentVector; //导入依赖的package包/类
@Override
public IList delete(IValue x) {
ITransientVector result = PersistentVector.EMPTY.asTransient();
boolean skipped = false;
for(Object item : (Iterable<?>) xs) {
if (!skipped && item.equals(x)) {
skipped = true;
} else {
result = (ITransientVector) result.conj(item);
}
}
return new Vector(getElementType(), (IPersistentVector) result.persistent());
}
示例5: select
import clojure.lang.IPersistentVector; //导入依赖的package包/类
@Override
public IValue select(int... fields) throws IndexOutOfBoundsException {
Type resultType = getType().select(fields);
if (resultType.isTuple()) {
ITransientVector resultVector = PersistentVector.EMPTY.asTransient();
for (int i : fields) {
resultVector = (ITransientVector) resultVector.conj(xs.nth(i));
}
return new Tuple(resultType, (IPersistentVector) resultVector.persistent());
} else {
return get(fields[0]);
}
}
示例6: intoClojureList
import clojure.lang.IPersistentVector; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static <T> ClojureList<T> intoClojureList(List<? extends T> list) {
if (list instanceof ClojureList) return (ClojureList<T>) list;
if (list instanceof IPersistentVector) return (ClojureList<T>) ClojureList.wrap((IPersistentVector) list);
// Work around an inference bug in some older JDKs
Collector<T, TransientList<T>, ClojureList<T>> collector = toClojureList();
return list.stream().collect(collector);
}
示例7: toJava
import clojure.lang.IPersistentVector; //导入依赖的package包/类
/**
* Turn a Clojure result into an object that is easier for Java to handle.
*
* @param result The result value to wrap.
* @param <T> The type of the return value.
* @return If the result is a core Clojure collection, returns an instanceof IClojureIterable, else returns result.
*/
@SuppressWarnings("unchecked")
public static <T> T toJava(Object result) {
if (result instanceof IPersistentMap) {
return (T) new ClojureMap((IPersistentMap) result);
} else if (result instanceof IPersistentVector) {
return (T) new ClojureVector((IPersistentVector) result);
} else if (result instanceof ISeq) {
return (T) new ClojureSeq((ISeq) result);
} else if (result instanceof Seqable) {
return (T) new ClojureSeq(((Seqable)result).seq());
}
return (T) result;
}
示例8: persistentVec
import clojure.lang.IPersistentVector; //导入依赖的package包/类
public static IPersistentVector persistentVec(final Object... init) {
return RT.vector(init);
}
示例9: TridentTupleView
import clojure.lang.IPersistentVector; //导入依赖的package包/类
public TridentTupleView(IPersistentVector delegates, ValuePointer[] index, Map<String, ValuePointer> fieldIndex) {
_delegates = delegates;
_index = index;
_fieldIndex = fieldIndex;
}
示例10:
import clojure.lang.IPersistentVector; //导入依赖的package包/类
public final static IPersistentVector core$vec(IPersistentCollection xs) {
return (IPersistentVector) core$vec.invoke(xs);
}
示例11: insertAt
import clojure.lang.IPersistentVector; //导入依赖的package包/类
private void insertAt(int i, ISeq ys) {
IPersistentVector tmp = (IPersistentVector) xs.persistent();
xs = PersistentVector.create(core$concat(core$concat(core$take(i, tmp), ys), core$drop(i, tmp))).asTransient();
}
示例12: Vector
import clojure.lang.IPersistentVector; //导入依赖的package包/类
protected Vector(Type et, IPersistentVector xs) {
this.ct = inferListOrRelType(et, xs.count() == 0);
this.xs = xs;
}
示例13: append
import clojure.lang.IPersistentVector; //导入依赖的package包/类
@Override
public IList append(IValue newItem) {
return new Vector(this.lub(newItem), (IPersistentVector) xs.cons(newItem));
}
示例14: replaceInSeq
import clojure.lang.IPersistentVector; //导入依赖的package包/类
protected static ISeq replaceInSeq(ISeq xs, int i, IValue x) {
IPersistentVector leftRight = core$splitAt(i, xs);
ISeq newLeft = (ISeq) leftRight.nth(0);
ISeq newRight = (ISeq) core$cons.invoke(x, core$next((IPersistentCollection) leftRight.nth(1)));
return core$concat(newLeft, newRight);
}
示例15: Tuple
import clojure.lang.IPersistentVector; //导入依赖的package包/类
protected Tuple(Type type, IPersistentVector xs) {
super(type);
this.xs = xs;
if (!type.isTuple())
throw new RuntimeException();
}