public static <V> BTreeSet<V> wrap(Object[] btree, Comparator<V> comparator) { return new BTreeSet<>(btree, comparator); }
@Override public SortedSet<V> headSet(V toElement) { return headSet(toElement, false); }
public NavigableSet<ClusteringBound> buildBound(boolean isStart, boolean isInclusive) { built = true; if (hasMissingElements) return BTreeSet.empty(comparator); CBuilder builder = CBuilder.create(comparator); if (elementsList.isEmpty()) return BTreeSet.of(comparator, builder.buildBound(isStart, isInclusive)); // Use a TreeSet to sort and eliminate duplicates BTreeSet.Builder<ClusteringBound> set = BTreeSet.builder(comparator); for (int i = 0, m = elementsList.size(); i < m; i++) { List<ByteBuffer> elements = elementsList.get(i); set.add(builder.buildBoundWith(elements, isStart, isInclusive)); } return set.build(); } }
@Override public <T> T[] toArray(T[] a) { return toArray(a, 0); }
@Override public BTreeSearchIterator<V, V> descendingIterator() { return slice(Dir.DESC); }
@Override public BTreeSet<V> headSet(V toElement, boolean inclusive) { return super.tailSet(toElement, inclusive).descendingSet(); }
public Builder addAll(PartitionColumns columns) { if (regularColumns == null && !columns.regulars.isEmpty()) regularColumns = BTreeSet.builder(naturalOrder()); for (ColumnDefinition c : columns.regulars) regularColumns.add(c); if (staticColumns == null && !columns.statics.isEmpty()) staticColumns = BTreeSet.builder(naturalOrder()); for (ColumnDefinition c : columns.statics) staticColumns.add(c); return this; }
@Override public SortedSet<V> subSet(V fromElement, V toElement) { return subSet(fromElement, true, toElement, false); }
@Override public <T> T[] toArray(T[] a) { int size = size(); if (a.length < size) a = Arrays.copyOf(a, size); int i = 0; for (V v : this) a[i++] = (T) v; return a; }
@Override public SortedSet<V> tailSet(V fromElement) { return tailSet(fromElement, true); }
@Override public boolean containsAll(Collection<?> c) { // TODO: if we ever use this method, it can be specialized quite easily for SortedSet arguments for (Object o : c) if (!contains(o)) return false; return true; }
public NavigableSet<ClusteringBound> buildBound(boolean isStart, boolean isInclusive) { built = true; if (hasMissingElements) return BTreeSet.empty(comparator); CBuilder builder = CBuilder.create(comparator); if (elementsList.isEmpty()) return BTreeSet.of(comparator, builder.buildBound(isStart, isInclusive)); // Use a TreeSet to sort and eliminate duplicates BTreeSet.Builder<ClusteringBound> set = BTreeSet.builder(comparator); for (int i = 0, m = elementsList.size(); i < m; i++) { List<ByteBuffer> elements = elementsList.get(i); set.add(builder.buildBoundWith(elements, isStart, isInclusive)); } return set.build(); } }
@Override public Object[] toArray() { return toArray(new Object[0]); }
@Override public BTreeSearchIterator<V, V> descendingIterator() { return slice(Dir.DESC); }
@Override public BTreeSet<V> headSet(V toElement, boolean inclusive) { return super.tailSet(toElement, inclusive).descendingSet(); }
public Builder addAll(PartitionColumns columns) { if (regularColumns == null && !columns.regulars.isEmpty()) regularColumns = BTreeSet.builder(naturalOrder()); for (ColumnDefinition c : columns.regulars) regularColumns.add(c); if (staticColumns == null && !columns.statics.isEmpty()) staticColumns = BTreeSet.builder(naturalOrder()); for (ColumnDefinition c : columns.statics) staticColumns.add(c); return this; }
@Override public SortedSet<V> subSet(V fromElement, V toElement) { return subSet(fromElement, true, toElement, false); }
public <T> T[] toArray(T[] a, int offset) { int size = size(); if (a.length < size + offset) a = Arrays.copyOf(a, size); BTree.toArray(tree, a, offset); return a; }
@Override public SortedSet<V> tailSet(V fromElement) { return tailSet(fromElement, true); }