/** * Creates a new tree set copying the elements of an array. * * @param a * an array to be copied into the new tree set. */ public ShortRBTreeSet(final short[] a) { this(); int i = a.length; while (i-- != 0) add(a[i]); } /**
/** * Creates a new tree set copying a given collection. * * @param c * a collection to be copied into the new tree set. */ public ShortRBTreeSet(final Collection<? extends Short> c) { this(); addAll(c); } /**
public AssociationRuleMining(ShortColumn sets, ShortColumn items, double support) { Table temp = Table.create("temp"); temp.addColumn(sets.copy()); temp.addColumn(items.copy()); temp.sortAscendingOn(sets.name(), items.name()); ViewGroup baskets = temp.splitOn(temp.column(0)); int[][] itemsets = new int[baskets.size()][]; int basketIndex = 0; for (TemporaryView basket : baskets) { ShortRBTreeSet set = new ShortRBTreeSet(basket.shortColumn(1).data()); int itemIndex = 0; itemsets[basketIndex] = new int[set.size()]; for (short item : set) { itemsets[basketIndex][itemIndex] = item; itemIndex++; } basketIndex++; } this.model = new ARM(itemsets, support); }
public ColumnStore(GraphStore graphStore, Class<T> elementType, boolean indexed) { if (MAX_SIZE >= Short.MAX_VALUE - Short.MIN_VALUE + 1) { throw new RuntimeException("Column Store size can't exceed 65534"); } this.graphStore = graphStore; this.configuration = graphStore != null ? graphStore.configuration : new Configuration(); this.lock = GraphStoreConfiguration.ENABLE_AUTO_LOCKING ? new TableLock() : null; this.garbageQueue = new ShortRBTreeSet(); this.idMap = new Object2ShortOpenHashMap<String>(MAX_SIZE); this.columns = new ColumnImpl[MAX_SIZE]; this.elementType = elementType; this.indexStore = indexed ? new IndexStore<T>(this) : null; idMap.defaultReturnValue(NULL_SHORT); this.observers = GraphStoreConfiguration.ENABLE_OBSERVERS ? new ArrayList<TableObserverImpl>() : null; }
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { s.defaultReadObject(); /* * The storedComparator is now correctly set, but we must restore on-the-fly the * actualComparator. */ setActualComparator(); allocatePaths(); if (count != 0) { tree = readTree(s, count, null, null); Entry e; e = tree; while (e.left() != null) e = e.left(); firstEntry = e; e = tree; while (e.right() != null) e = e.right(); lastEntry = e; } } }
@Override public boolean remove(final short k) { if (!in(k)) return false; return ShortRBTreeSet.this.remove(k); } @Override
@Override public boolean contains(final short k) { return findKey(k) != null; } @Override
@Override public boolean contains(final short k) { return in(k) && ShortRBTreeSet.this.contains(k); } @Override
throw new InternalError(); c.allocatePaths(); if (count != 0) {
public FrequentItemset(ShortColumn sets, ShortColumn items, double support) { Table temp = Table.create("temp"); temp.addColumn(sets.copy()); temp.addColumn(items.copy()); temp.sortAscendingOn(sets.name(), items.name()); ViewGroup baskets = temp.splitOn(temp.column(0)); this.setCount = baskets.size(); int[][] itemsets = new int[setCount][]; int basketIndex = 0; for (TemporaryView basket : baskets) { ShortRBTreeSet set = new ShortRBTreeSet(basket.shortColumn(1).data()); int itemIndex = 0; itemsets[basketIndex] = new int[set.size()]; for (short item : set) { itemsets[basketIndex][itemIndex] = item; itemIndex++; } basketIndex++; } this.model = new FPGrowth(itemsets, support); }
public ColumnStore(GraphStore graphStore, Class<T> elementType, boolean indexed) { if (MAX_SIZE >= Short.MAX_VALUE - Short.MIN_VALUE + 1) { throw new RuntimeException("Column Store size can't exceed 65534"); } this.graphStore = graphStore; this.configuration = graphStore != null ? graphStore.configuration : new Configuration(); this.lock = GraphStoreConfiguration.ENABLE_AUTO_LOCKING ? new TableLock() : null; this.garbageQueue = new ShortRBTreeSet(); this.idMap = new Object2ShortOpenHashMap<String>(MAX_SIZE); this.columns = new ColumnImpl[MAX_SIZE]; this.elementType = elementType; this.indexStore = indexed ? new IndexStore<T>(this) : null; idMap.defaultReturnValue(NULL_SHORT); this.observers = GraphStoreConfiguration.ENABLE_OBSERVERS ? new ArrayList<TableObserverImpl>() : null; }
/** * Creates a new subset with given key range. * * @param from * the start of the subset range. * @param bottom * if true, the first parameter is ignored and the range starts from * -∞. * @param to * the end of the subset range. * @param top * if true, the third parameter is ignored and the range goes to * ∞. */ public Subset(final short from, final boolean bottom, final short to, final boolean top) { if (!bottom && !top && ShortRBTreeSet.this.compare(from, to) > 0) throw new IllegalArgumentException( "Start element (" + from + ") is larger than end element (" + to + ")"); this.from = from; this.bottom = bottom; this.to = to; this.top = top; } @Override
@Override public void remove() { if (curr == null) throw new IllegalStateException(); /* * If the last operation was a next(), we are removing an entry that preceeds * the current index, and thus we must decrement it. */ if (curr == prev) index--; next = prev = curr; updatePrevious(); updateNext(); ShortRBTreeSet.this.remove(curr.key); curr = null; } }
/** * Locates the first entry. * * @return the first entry of this subset, or {@code null} if the subset is * empty. */ public ShortRBTreeSet.Entry firstEntry() { if (tree == null) return null; // If this subset goes to -infinity, we return the main set first entry; // otherwise, we locate the start of the set. ShortRBTreeSet.Entry e; if (bottom) e = firstEntry; else { e = locateKey(from); // If we find either the start or something greater we're OK. if (compare(e.key, from) < 0) e = e.next(); } // Finally, if this subset doesn't go to infinity, we check that the resulting // key isn't greater than the end. if (e == null || !top && compare(e.key, to) >= 0) return null; return e; } /**
public EdgeTypeStore(Configuration config) { if (MAX_SIZE >= Short.MAX_VALUE - Short.MIN_VALUE + 1) { throw new RuntimeException("Edge Type Store size can't exceed 65534"); } this.configuration = config; this.garbageQueue = new ShortRBTreeSet(); this.labelMap = new Object2ShortOpenHashMap(MAX_SIZE); this.idMap = new Short2ObjectOpenHashMap(MAX_SIZE); labelMap.defaultReturnValue(NULL_SHORT); // Add null type short id = intToShort(NULL_LABEL); length++; labelMap.put(null, id); idMap.put(id, null); }
@Override void updateNext() { next = next.next(); if (!top && next != null && ShortRBTreeSet.this.compare(next.key, to) >= 0) next = null; } }
/** * Creates a new tree set copying the elements of an array using a given * {@link Comparator}. * * @param a * an array to be copied into the new tree set. * @param c * a {@link Comparator} (even better, a type-specific comparator). */ public ShortRBTreeSet(final short[] a, final Comparator<? super Short> c) { this(c); int i = a.length; while (i-- != 0) add(a[i]); } /*