org.apache.commons.collections4.list.TreeList Java Examples
The following examples show how to use
org.apache.commons.collections4.list.TreeList.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QueryExpDeltaCoEval.java From CQL with GNU Affero General Public License v3.0 | 6 votes |
private static <Ty, En, Sym, Fk, Att, Gen, Sk, X, Y> List<List<Term<Ty, En, Sym, Fk, Att, Gen, Sk>>> helper( Instance<Ty, En, Sym, Fk, Att, Gen, Sk, X, Y> j, Pair<List<Ty>, Ty> pair, Set<Term<Ty, En, Sym, Fk, Att, Gen, Sk>> set) { List<List<Term<Ty, En, Sym, Fk, Att, Gen, Sk>>> ret = new TreeList<>(); ret.add(new TreeList<>()); for (Ty t : pair.first) { List<List<Term<Ty, En, Sym, Fk, Att, Gen, Sk>>> ret2 = new TreeList<>(); for (Term<Ty, En, Sym, Fk, Att, Gen, Sk> l : getForTy(j, Chc.inLeft(t), set)) { for (List<Term<Ty, En, Sym, Fk, Att, Gen, Sk>> x : ret) { List<Term<Ty, En, Sym, Fk, Att, Gen, Sk>> z = new TreeList<>(x); z.add(l); ret2.add(z); } } ret = ret2; } return ret; }
Example #2
Source File: InstExpQueryQuotient.java From CQL with GNU Affero General Public License v3.0 | 6 votes |
public InstExpQueryQuotient(InstExp<Gen, Sk, X, Y> i, List<Pair<LocStr, PreBlock>> list, List<Pair<String, String>> options) { I = i; this.options = Util.toMapSafely(options); this.queries = Util.toSetSafely(list).stream().map(x -> new Block(x.second, x.first, x.second.star)) .collect(Collectors.toSet()); for (Pair<LocStr, PreBlock> p : list) { List<InteriorLabel<Object>> f = new TreeList<>(); if (p.second.star) { throw new RuntimeException("Cannot use *"); } f.add(new InteriorLabel<>("entities", p.second, p.first.loc, x -> p.first.str).conv()); raw.put(p.first.str, f); } }
Example #3
Source File: CmsPlan.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
/** * 从组织查询条件,信息类文档 * * @param cb * @param root * @return * @throws Exception */ private Predicate documentPredicate(CriteriaBuilder cb, Root<Document> root) throws Exception { List<Predicate> ps = new TreeList<>(); ps.add(this.documentPredicate_creator(cb, root)); ps.add(this.documentPredicate_appInfo(cb, root)); ps.add(this.documentPredicate_date(cb, root)); Predicate predicate = this.documentPredicate_typeScope(cb, root); if( predicate != null ) { ps.add( predicate ); } ps = ListTools.trim( ps, true, false); if (ps.isEmpty()) { throw new Exception("where is empty."); } cb.and(ps.toArray(new Predicate[] {})); return cb.and(ps.toArray(new Predicate[] {})); }
Example #4
Source File: MonoidalProver.java From CQL with GNU Affero General Public License v3.0 | 6 votes |
private List<Chc<Chc<Unit, T>, C>> trans(Map<V, T> ctx, KBExp<C, V> term) { List<Chc<Chc<Unit, T>, C>> ret = (new TreeList<>()); while (true) { if (term.isVar()) { break; } else if (term.getArgs().isEmpty() && ctx.isEmpty()) { ret.add(0, Chc.inRight(term.f())); break; } else if (term.getArgs().isEmpty() && !ctx.isEmpty()) { Chc<Unit, T> t = ctx.isEmpty() ? Chc.inLeft(Unit.unit) : Chc.inRight(ctx.values().iterator().next()); ret.add(0, Chc.inRight(term.f())); ret.add(0, Chc.inLeft(t)); break; } else { ret.add(0, Chc.inRight(term.f())); term = term.getArgs().get(0); } } return ret; // Util.reverse(ret); }
Example #5
Source File: Thue.java From CQL with GNU Affero General Public License v3.0 | 6 votes |
private boolean close1_h(Set<ConsList<X>> ret, ConsList<X> e, int i, ConsList<X> rule1, ConsList<X> rule2, ConsList<X> f0) { List<X> test = e.list.subList(i, i + rule1.size()); if (!test.equals(rule1.list)) { return false; } List<X> ret2 = new TreeList<>(e.list); delete(ret2, i, rule1.size()); add(ret2, i, rule2.list); ConsList<X> ll = ConsList.new0(ret2, false); ret.add(ll); return f0.equals(ll); }
Example #6
Source File: Plan.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
private List<SelectEntry> listOrderSelectEntry() { List<SelectEntry> list = new TreeList<>(); SelectEntry _g = this.findGroupSelectEntry(); if (null != _g) { if (StringUtils.equals(SelectEntry.ORDER_ASC, _g.orderType) || StringUtils.equals(SelectEntry.ORDER_DESC, _g.orderType)) { list.add(_g); } } for (SelectEntry _o : this.selectList) { if (StringUtils.equals(SelectEntry.ORDER_ASC, _o.orderType) || StringUtils.equals(SelectEntry.ORDER_DESC, _o.orderType)) { list.add(_o); } } return list; }
Example #7
Source File: EntityManagerContainer.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
public <T extends JpaObject> List<T> listEqualAndEqual(Class<T> cls, String attribute, Object value, String otherAttribute, Object otherValue) throws Exception { EntityManager em = this.get(cls); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<T> cq = cb.createQuery(cls); Root<T> root = cq.from(cls); cq.select(root) .where(cb.and(cb.equal(root.get(attribute), value), cb.equal(root.get(otherAttribute), otherValue))); List<T> os = em.createQuery(cq).getResultList(); return new TreeList<T>(os); }
Example #8
Source File: ProcessPlatformPlan.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
private Predicate workCompletedPredicate(CriteriaBuilder cb, Root<WorkCompleted> root) throws Exception { List<Predicate> ps = new TreeList<>(); ps.add(this.workCompletedPredicate_application(cb, root)); ps.add(this.workCompletedPredicate_creator(cb, root)); ps.add(this.workCompletedPredicate_date(cb, root)); ps = ListTools.trim(ps, true, false); if (ps.isEmpty()) { throw new Exception("where is empty."); } return cb.and(ps.toArray(new Predicate[] {})); }
Example #9
Source File: ProcessPlatformPlan.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
private Predicate workPredicate(CriteriaBuilder cb, Root<Work> root) throws Exception { List<Predicate> ps = new TreeList<>(); ps.add(this.workPredicate_application(cb, root)); ps.add(this.workPredicate_creator(cb, root)); ps.add(this.workPredicate_date(cb, root)); ps = ListTools.trim(ps, true, false); if (ps.isEmpty()) { throw new Exception("where is empty."); } return cb.and(ps.toArray(new Predicate[] {})); }
Example #10
Source File: ProcessPlatformPlan.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
public ProcessPlatformPlan(Runtime runtime) { this.runtime = runtime; this.selectList = new SelectEntries(); this.where = new WhereEntry(); this.filterList = new TreeList<FilterEntry>(); // this.calculate = new Calculate(); this.columnList = new TreeList<String>(); }
Example #11
Source File: CmsPlan.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
public CmsPlan(Runtime runtime) { this.runtime = runtime; this.selectList = new SelectEntries(); this.where = new WhereEntry(); this.filterList = new TreeList<FilterEntry>(); //this.calculate = new Calculate(); this.columnList = new TreeList<String>(); }
Example #12
Source File: EntityManagerContainer.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
public <T extends JpaObject> List<T> listEqualAndEqualAndNotEqual(Class<T> cls, String equalAttribute, Object equalValue, String otherEqualAttribute, Object otherEqualValue, String notEqualAttribute, Object notEqualValue) throws Exception { EntityManager em = this.get(cls); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<T> cq = cb.createQuery(cls); Root<T> root = cq.from(cls); cq.select(root) .where(cb.and(cb.equal(root.get(equalAttribute), equalValue), cb.equal(root.get(otherEqualAttribute), otherEqualValue), cb.notEqual(root.get(notEqualAttribute), notEqualValue))); List<T> os = em.createQuery(cq).getResultList(); return new TreeList<T>(os); }
Example #13
Source File: EntityManagerContainer.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
public <T extends JpaObject> List<T> listEqualAndNotEqual(Class<T> cls, String equalAttribute, Object equalValue, String notEqualAttribute, Object notEqualValue) throws Exception { EntityManager em = this.get(cls); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<T> cq = cb.createQuery(cls); Root<T> root = cq.from(cls); cq.select(root).where(cb.and(cb.equal(root.get(equalAttribute), equalValue), cb.notEqual(root.get(notEqualAttribute), notEqualValue))); List<T> os = em.createQuery(cq).getResultList(); return new TreeList<T>(os); }
Example #14
Source File: EntityManagerContainer.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
public <T extends JpaObject> List<T> listEqualAndEqualAndEqualAndNotEqual(Class<T> cls, String firstAttribute, Object firstValue, String secondAttribute, Object secondValue, String thirdAttribute, Object thirdValue, String fourthAttribute, Object fourthValue) throws Exception { EntityManager em = this.get(cls); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<T> cq = cb.createQuery(cls); Root<T> root = cq.from(cls); cq.select(root).where(cb.and(cb.equal(root.get(firstAttribute), firstValue), cb.equal(root.get(secondAttribute), secondValue), cb.equal(root.get(thirdAttribute), thirdValue), cb.notEqual(root.get(fourthAttribute), fourthValue))); List<T> os = em.createQuery(cq).getResultList(); return new TreeList<T>(os); }
Example #15
Source File: EntityManagerContainer.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
public <T extends JpaObject> List<T> listEqualAndEqualAndEqual(Class<T> cls, String attribute, Object value, String otherAttribute, Object otherValue, String thirdAttribute, Object thirdValue) throws Exception { EntityManager em = this.get(cls); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<T> cq = cb.createQuery(cls); Root<T> root = cq.from(cls); cq.select(root).where(cb.and(cb.equal(root.get(attribute), value), cb.equal(root.get(otherAttribute), otherValue), cb.equal(root.get(thirdAttribute), thirdValue))); List<T> os = em.createQuery(cq).getResultList(); return new TreeList<T>(os); }
Example #16
Source File: LPOUKB.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
private static <C> Pair<Integer, List<C>> toPrec(Map<C, Integer> cs, DAG<C> g) { List<C> ret = new TreeList<>(g.topologicalSort()); // biggest first List<C> extra = new TreeList<>(cs.keySet()); // biggest first extra.removeAll(g.vertices()); int i = 0; for (C c : ret) { i += cs.get(c); } ret.addAll(0, extra); return new Pair<>(i, (Util.reverse(ret))); }
Example #17
Source File: LPOUKB.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
private boolean strongGroundJoinable(BiFunction<Chc<V, C>, Chc<V, C>, Boolean> gt, KBExp<C, V> s, KBExp<C, V> t, Map<V, T> ctx) { List<Triple<KBExp<C, V>, KBExp<C, V>, Map<V, T>>> R0 = new TreeList<>(); if (!s.equals(red(gt, null, G, R0, s, ctx.values()))) { return false; } if (!t.equals(red(gt, null, G, R0, t, ctx.values()))) { return false; } for (Triple<KBExp<C, V>, KBExp<C, V>, Map<V, T>> e : E) { // TODO aql was E0 = empty Map<V, KBExp<C, V>> m = subsumes0(new Triple<>(s, t, ctx), e); if (m == null) { m = subsumes0(new Triple<>(t, s, ctx), e); } if (m == null) { m = subsumes0(new Triple<>(s, t, ctx), e.reverse12()); } if (m == null) { m = subsumes0(new Triple<>(s, t, ctx), e.reverse12()); } if (m == null) { continue; } return false; } return eqUpToSorting(s, t, ctx.values()); }
Example #18
Source File: Thue.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
private synchronized ConsList<X> normal_form(ConsList<X> e) { if (e.isEmpty()) { return e; } // ConsList<X> tt = t.nf_cache.map.get(e); // if (tt != null) { // return tt; // } Iterator<X> it = e.iterator(); int j = 0; while (it.hasNext()) { int i = j; j++; X x = it.next(); for (Pair<ConsList<X>, ConsList<X>> rule : rs.get(x)) { if (rule.first.size() > e.size() - i) { continue; } ConsList<X> test = e.subList(i, i + rule.first.size(), false); if (!test.equals(rule.first)) { continue; } List<X> ret2 = new TreeList<>(e.list); delete(ret2, i, rule.first.size()); add(ret2, i, rule.second.list); ConsList<X> ret = ConsList.new0(ret2, false); if (!e.equals(ret)) { ConsList<X> z = normal_form(ret); return z; } return e; } } // t.nf_cache.put(e, e); return e; }
Example #19
Source File: Util.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
public static <X, Y> Map<X, List<Y>> newListsFor(Collection<X> xs) { Map<X, List<Y>> ret = new THashMap<>(xs.size()); for (X x : xs) { ret.put(x, (new TreeList<>())); } return ret; }
Example #20
Source File: InstExpImport.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
public InstExpImport(SchExp schema, List<Pair<LocStr, Q>> map, List<Pair<String, String>> options) { this.schema = schema; this.options = Util.toMapSafely(options); this.map = Util.toMapSafely(LocStr.set2(map)); List<InteriorLabel<Object>> f = new TreeList<>(); for (Pair<LocStr, Q> p : map) { f.add(new InteriorLabel<>("imports", new Pair<>(p.first.str, p.second), p.first.loc, x -> x.first + " -> " + x.second).conv()); } raw.put("imports", f); }
Example #21
Source File: AqlTyping.java From CQL with GNU Affero General Public License v3.0 | 4 votes |
public AqlTyping() { prog = new Program<>(new TreeList<>(), ""); }
Example #22
Source File: CompletionProver.java From CQL with GNU Affero General Public License v3.0 | 4 votes |
@SuppressWarnings("unchecked") public CompletionProver(AqlOptions ops, KBTheory<Chc<Ty, En>, Head<Ty, En, Sym, Fk, Att, Gen, Sk>, Var> xx, List<Head<Ty, En, Sym, Fk, Att, Gen, Sk>> prec2) { super(xx); boolean sort = (Boolean) ops.getOrDefault(AqlOption.completion_sort); boolean filter_subsumed = (Boolean) ops.getOrDefault(AqlOption.completion_filter_subsumed); boolean compose = (Boolean) ops.getOrDefault(AqlOption.completion_compose); boolean syntactic_ac = (Boolean) ops.getOrDefault(AqlOption.completion_syntactic_ac); boolean unfailing = (Boolean) ops.getOrDefault(AqlOption.completion_unfailing); Collection<Triple<KBExp<Head<Ty, En, Sym, Fk, Att, Gen, Sk>, Var>, KBExp<Head<Ty, En, Sym, Fk, Att, Gen, Sk>, Var>, Map<Var, Chc<Ty, En>>>> E0 = kb.eqs.stream().map(x -> new Triple<>(x.second, x.third, x.first)).collect(Collectors.toList()); if (prec2 == null) { Map<Head<Ty, En, Sym, Fk, Att, Gen, Sk>, Integer> m = new THashMap<>(); for (Head<Ty, En, Sym, Fk, Att, Gen, Sk> c : kb.syms.keySet()) { m.put(c, kb.syms.get(c).first.size()); } prec2 = LPOUKB.inferPrec(m, E0); } List<Head<Ty, En, Sym, Fk, Att, Gen, Sk>> prec = new TreeList<>(prec2); /* for (Head<Ty, En, Sym, Fk, Att, Gen, Sk> c : init) { if (!kb.syms.keySet().contains(c)) { prec.remove(c); // simplfied away } } if (!prec.isEmpty() && prec.get(0) == null) { throw new RuntimeException("Anomaly: please report"); }*/ KBOptions options = new KBOptions(unfailing, sort, false, true, Integer.MAX_VALUE, Integer.MAX_VALUE, filter_subsumed, compose, syntactic_ac); // this ignores all but 4 options, see LPOUKB //Util.assertNoDups(prec); Set<Head<Ty, En, Sym, Fk, Att, Gen, Sk>> sigMinusPrec = (new THashSet<>(kb.syms.keySet())); sigMinusPrec.removeAll(prec); if (!sigMinusPrec.isEmpty() && !kb.syms.keySet().isEmpty()) { throw new RuntimeException( "Incorrect precedence. Symbols in signature but not precedence: " + sigMinusPrec); } cp = new LPOUKB<>(E0, VarIt.it(), Collections.emptySet(), options, prec, kb); }
Example #23
Source File: Plan.java From o2oa with GNU Affero General Public License v3.0 | 4 votes |
private Table order(Table table) { Comparator<Row> comparator = new Comparator<Row>() { @SuppressWarnings({ "rawtypes", "unchecked" }) public int compare(Row r1, Row r2) { int comp = 0; Object o1 = null; Object o2 = null; Comparable c1 = null; Comparable c2 = null; for (SelectEntry en : orderList) { o1 = r1.find(en.column); o2 = r2.find(en.column); if (null == o1 && null == o2) { comp = 0; } else if (null == o1) { comp = -1; } else if (null == o2) { comp = 1; } else { if (o1.getClass() == o2.getClass()) { c1 = (Comparable) o1; c2 = (Comparable) o2; } else { c1 = o1.toString(); c2 = o2.toString(); } if (StringUtils.equals(SelectEntry.ORDER_ASC, en.orderType)) { comp = c1.compareTo(c2); } else { comp = c2.compareTo(c1); } } if (comp != 0) { return comp; } } return comp; } }; List<Row> list = new TreeList<>(); if ((null != table) && (!table.isEmpty()) && (!orderList.isEmpty())) { list = table.stream().sorted(comparator).collect(Collectors.toList()); table.clear(); table.addAll(list); } return table; }
Example #24
Source File: Util.java From CQL with GNU Affero General Public License v3.0 | 4 votes |
public static <X> List<X> diff(Collection<X> l, Collection<?> r) { List<X> ret = new TreeList<>(l); ret.removeAll(r); return ret; }
Example #25
Source File: InstExpQueryQuotient.java From CQL with GNU Affero General Public License v3.0 | 4 votes |
private Instance<Ty, En, Sym, Fk, Att, Gen, Sk, Integer, Chc<Sk, Pair<Integer, Att>>> evalProver(AqlEnv env, Instance<Ty, En, Sym, Fk, Att, Gen, Sk, X, Y> I0, EvalInstance<Ty, En, Sym, Fk, Att, Gen, Sk, En, Void, Void, X, Y> J) { Collage<Ty, En, Sym, Fk, Att, Gen, Sk> col = new CCollage<>(I0.collage()); List<Pair<Term<Ty, En, Sym, Fk, Att, Gen, Sk>, Term<Ty, En, Sym, Fk, Att, Gen, Sk>>> eqs0 = new LinkedList<>( ); AqlOptions strat = new AqlOptions(options, env.defaults); I0.eqs((a,b)->{ eqs0.add(new Pair<>(a, b)); col.eqs().add(new Eq<>(null, a.convert(), b.convert())); }); J.gens().keySet((p) -> { Map<catdata.aql.Var, Chc<X, Term<Ty, En, Sym, Fk, Att, Gen, Sk>>> m = p.asMap(); List<Var> vs = new TreeList<>(m.keySet()); Var v1 = vs.get(0); Var v2 = vs.get(1); Chc<X, Term<Ty, En, Sym, Fk, Att, Gen, Sk>> x1 = p.get(v1); Chc<X, Term<Ty, En, Sym, Fk, Att, Gen, Sk>> x2 = p.get(v2); Term<Void, En, Void, Fk, Void, Gen, Void> t1 = I0.algebra().repr(p.en2(), x1.l); Term<Void, En, Void, Fk, Void, Gen, Void> t2 = I0.algebra().repr(p.en2(), x2.l); if (!t1.equals(t2)) { eqs0.add(new Pair<>(t1.convert(), t2.convert())); col.eqs().add(new Eq<>(null, t1.convert(), t2.convert())); } }); InitialAlgebra<Ty, En, Sym, Fk, Att, Gen, Sk> initial0 = new InitialAlgebra<>(strat, I0.schema(), col, (y) -> y, (x, y) -> y); LiteralInstance<Ty, En, Sym, Fk, Att, Gen, Sk, Integer, Chc<Sk, Pair<Integer, Att>>> ret = new LiteralInstance<>( I0.schema(), col.gens(), col.sks(), eqs0, initial0.dp(), initial0, (Boolean) strat.getOrDefault(AqlOption.require_consistency), (Boolean) strat.getOrDefault(AqlOption.allow_java_eqs_unsafe)); return ret; }
Example #26
Source File: Calculate.java From o2oa with GNU Affero General Public License v3.0 | 4 votes |
public Calculate() { this.isGroup = false; this.calculateList = new TreeList<CalculateEntry>(); }
Example #27
Source File: CommonCollections.java From j360-dubbo-app-all with Apache License 2.0 | 2 votes |
/** * ArrayList 与 LinkedList的折衷版 * * ArrayList 随机访问快,当非末尾的插入删除慢. LinkedList的插入删除快,但非两端的操作都需要遍历链表到达指定下标. * * TreeList是内部结构为TreeNode的Linked List, 与Linked相仿,但能更快的到达指定下标. */ public static <E> TreeList<E> treeList() { return new TreeList<E>(); }