| 14 | import org.pcollections.PVector; |
| 15 | |
| 16 | public abstract class PList<V> extends Collection implements List<V> { |
| 17 | @NotNull PVector<V> list = Empty.vector(); |
| 18 | |
| 19 | @Override |
| 20 | public abstract boolean add(@NotNull V item); |
| 21 | |
| 22 | @Override |
| 23 | public abstract boolean remove(@NotNull Object item); |
| 24 | |
| 25 | @Override |
| 26 | public abstract void clear(); |
| 27 | |
| 28 | @Override |
| 29 | public abstract @NotNull V set(int index, @NotNull V item); |
| 30 | |
| 31 | @Override |
| 32 | public abstract void add(int index, @NotNull V item); |
| 33 | |
| 34 | @Override |
| 35 | public abstract @NotNull V remove(int index); |
| 36 | |
| 37 | @Override |
| 38 | public abstract boolean addAll(@NotNull java.util.Collection<? extends V> items); |
| 39 | |
| 40 | @Override |
| 41 | public abstract boolean removeAll(@NotNull java.util.Collection<?> c); |
| 42 | |
| 43 | @Deprecated // unsupported |
| 44 | @Override |
| 45 | public boolean retainAll(@NotNull java.util.Collection<?> c) { |
| 46 | throw new UnsupportedOperationException(); |
| 47 | } |
| 48 | |
| 49 | public final @NotNull PVector<V> getList() { |
| 50 | if (isManaged()) { |
| 51 | var txn = Transaction.getCurrentVerifyRead(this); |
| 52 | if (txn == null) |
| 53 | return list; |
| 54 | //noinspection DataFlowIssue |
| 55 | Log log = txn.getLog(parent().objectId() + variableId()); |
| 56 | if (log == null) |
| 57 | return list; |
| 58 | @SuppressWarnings("unchecked") |
| 59 | var listLog = (LogList<V>)log; |
| 60 | return listLog.getValue(); |
| 61 | } |
| 62 | return list; |
| 63 | } |
| 64 | |
| 65 | public final void copyTo(V @NotNull [] array, int arrayIndex) { |
| 66 | for (V v : getList()) |
| 67 | array[arrayIndex++] = v; |
| 68 | } |
| 69 | |
| 70 | @Override |
| 71 | public Object @NotNull [] toArray() { |
| 72 | return getList().toArray(); |
| 73 | } |
nothing calls this directly
no outgoing calls
no test coverage detected