MCPcopy
hub / github.com/questdb/questdb / ObjList

Class ObjList

core/src/main/java/io/questdb/std/ObjList.java:34–400  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32import java.util.Comparator;
33
34public class ObjList<T> implements Mutable, Sinkable, ReadOnlyObjList<T> {
35 private static final int DEFAULT_ARRAY_SIZE = 16;
36 private T[] buffer;
37 private int pos = 0;
38
39 @SuppressWarnings("unchecked")
40 public ObjList() {
41 this.buffer = (T[]) new Object[DEFAULT_ARRAY_SIZE];
42 }
43
44 @SuppressWarnings("unchecked")
45 public ObjList(ObjList<? extends T> other) {
46 this.buffer = (T[]) new Object[Math.max(other.size(), DEFAULT_ARRAY_SIZE)];
47 setPos(other.size());
48 System.arraycopy(other.buffer, 0, this.buffer, 0, pos);
49 }
50
51 @SafeVarargs
52 @SuppressWarnings("unchecked")
53 public ObjList(T... other) {
54 this.buffer = (T[]) new Object[Math.max(other.length, DEFAULT_ARRAY_SIZE)];
55 setPos(other.length);
56 System.arraycopy(other, 0, this.buffer, 0, pos);
57 }
58
59 @SuppressWarnings("unchecked")
60 public ObjList(int capacity) {
61 this.buffer = (T[]) new Object[Math.max(capacity, DEFAULT_ARRAY_SIZE)];
62 }
63
64 public void add(T value) {
65 checkCapacity(pos + 1);
66 buffer[pos++] = value;
67 }
68
69 public void addAll(ReadOnlyObjList<? extends T> that) {
70 int n = that.size();
71 checkCapacity(pos + n);
72 for (int i = 0; i < n; i++) {
73 buffer[pos++] = that.getQuick(i);
74 }
75 }
76
77 public void addAll(ReadOnlyObjList<? extends T> that, int lo, int hi) {
78 int n = hi - lo;
79 checkCapacity(pos + n);
80 for (int i = lo; i < hi; i++) {
81 buffer[pos++] = that.getQuick(i);
82 }
83 }
84
85 public void addReverseAll(ReadOnlyObjList<? extends T> that) {
86 int n = that.size();
87 checkCapacity(pos + n);
88 for (int i = n - 1; i >= 0; i--) {
89 buffer[pos++] = that.getQuick(i);
90 }
91 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…