summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/funcdata
diff options
context:
space:
mode:
authorbculkin2442 <bjculkin@mix.wvu.edu>2016-04-22 14:48:04 -0400
committerbculkin2442 <bjculkin@mix.wvu.edu>2016-04-22 14:48:04 -0400
commit42f7d379a430aaf2fad169f0170de04072b08b10 (patch)
tree5d46b43b2d9272f4e593820ee147b3ae3f0d82b0 /BJC-Utils2/src/main/java/bjc/utils/funcdata
parentb65b705c391bb772bc41269bce5243c1cc88969d (diff)
Formatting changes
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/funcdata')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/funcdata/ExtendedMap.java68
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalList.java48
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalMap.java120
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalStringTokenizer.java36
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/funcdata/IFunctionalList.java24
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/funcdata/IFunctionalMap.java120
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/funcdata/TransformedValueMap.java64
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTree.java34
8 files changed, 257 insertions, 257 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/ExtendedMap.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/ExtendedMap.java
index 7e4c7fd..9776961 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/ExtendedMap.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/ExtendedMap.java
@@ -19,49 +19,47 @@ class ExtendedMap<KeyType, ValueType>
}
@Override
- public ValueType put(KeyType key, ValueType val) {
- return store.put(key, val);
- }
-
- @Override
- public ValueType get(KeyType key) {
+ public boolean containsKey(KeyType key) {
if (store.containsKey(key)) {
- return store.get(key);
+ return true;
}
- return delegate.get(key);
+ return delegate.containsKey(key);
}
@Override
- public <MappedValue> IFunctionalMap<KeyType, MappedValue> mapValues(
- Function<ValueType, MappedValue> transformer) {
- return new TransformedValueMap<>(this, transformer);
+ public IFunctionalMap<KeyType, ValueType> extend() {
+ return new ExtendedMap<>(this, new FunctionalMap<>());
}
@Override
- public boolean containsKey(KeyType key) {
- if (store.containsKey(key)) {
- return true;
- }
+ public void forEach(BiConsumer<KeyType, ValueType> action) {
+ store.forEach(action);
- return delegate.containsKey(key);
+ delegate.forEach(action);
}
@Override
- public IFunctionalList<KeyType> keyList() {
- return ListUtils.mergeLists(store.keyList(), delegate.keyList());
+ public void forEachKey(Consumer<KeyType> action) {
+ store.forEachKey(action);
+
+ delegate.forEachKey(action);
}
@Override
- public void forEach(BiConsumer<KeyType, ValueType> action) {
- store.forEach(action);
+ public void forEachValue(Consumer<ValueType> action) {
+ store.forEachValue(action);
- delegate.forEach(action);
+ delegate.forEachValue(action);
}
@Override
- public ValueType remove(KeyType key) {
- return store.remove(key);
+ public ValueType get(KeyType key) {
+ if (store.containsKey(key)) {
+ return store.get(key);
+ }
+
+ return delegate.get(key);
}
@Override
@@ -70,17 +68,24 @@ class ExtendedMap<KeyType, ValueType>
}
@Override
- public void forEachKey(Consumer<KeyType> action) {
- store.forEachKey(action);
+ public IFunctionalList<KeyType> keyList() {
+ return ListUtils.mergeLists(store.keyList(), delegate.keyList());
+ }
- delegate.forEachKey(action);
+ @Override
+ public <MappedValue> IFunctionalMap<KeyType, MappedValue> mapValues(
+ Function<ValueType, MappedValue> transformer) {
+ return new TransformedValueMap<>(this, transformer);
}
@Override
- public void forEachValue(Consumer<ValueType> action) {
- store.forEachValue(action);
+ public ValueType put(KeyType key, ValueType val) {
+ return store.put(key, val);
+ }
- delegate.forEachValue(action);
+ @Override
+ public ValueType remove(KeyType key) {
+ return store.remove(key);
}
@Override
@@ -88,9 +93,4 @@ class ExtendedMap<KeyType, ValueType>
return ListUtils.mergeLists(store.valueList(),
delegate.valueList());
}
-
- @Override
- public IFunctionalMap<KeyType, ValueType> extend() {
- return new ExtendedMap<>(this, new FunctionalMap<>());
- }
}
diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalList.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalList.java
index c8f2269..8579693 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalList.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalList.java
@@ -358,6 +358,15 @@ public class FunctionalList<E> implements Cloneable, IFunctionalList<E> {
}
/*
+ * Check if a partition has room for another item
+ */
+ private Boolean isPartitionFull(int numberPerPartition,
+ IHolder<IFunctionalList<E>> currentPartition) {
+ return currentPartition.unwrap(
+ (partition) -> partition.getSize() >= numberPerPartition);
+ }
+
+ /*
* (non-Javadoc)
*
* @see
@@ -433,15 +442,6 @@ public class FunctionalList<E> implements Cloneable, IFunctionalList<E> {
}
/*
- * Check if a partition has room for another item
- */
- private Boolean isPartitionFull(int numberPerPartition,
- IHolder<IFunctionalList<E>> currentPartition) {
- return currentPartition.unwrap(
- (partition) -> partition.getSize() >= numberPerPartition);
- }
-
- /*
* (non-Javadoc)
*
* @see bjc.utils.funcdata.IFunctionalList#prepend(E)
@@ -522,6 +522,11 @@ public class FunctionalList<E> implements Cloneable, IFunctionalList<E> {
removeIf((element) -> element.equals(desiredElement));
}
+ @Override
+ public void reverse() {
+ Collections.reverse(wrappedList);
+ }
+
/*
* (non-Javadoc)
*
@@ -553,6 +558,16 @@ public class FunctionalList<E> implements Cloneable, IFunctionalList<E> {
Collections.sort(wrappedList, comparator);
}
+ @Override
+ public IFunctionalList<E> tail() {
+ return new FunctionalList<>(wrappedList.subList(1, getSize()));
+ }
+
+ @Override
+ public E[] toArray(E[] arrType) {
+ return wrappedList.toArray(arrType);
+ }
+
/*
* (non-Javadoc)
*
@@ -584,19 +599,4 @@ public class FunctionalList<E> implements Cloneable, IFunctionalList<E> {
return sb.toString();
}
-
- @Override
- public E[] toArray(E[] arrType) {
- return wrappedList.toArray(arrType);
- }
-
- @Override
- public IFunctionalList<E> tail() {
- return new FunctionalList<>(wrappedList.subList(1, getSize()));
- }
-
- @Override
- public void reverse() {
- Collections.reverse(wrappedList);
- }
} \ No newline at end of file
diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalMap.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalMap.java
index eaa425b..fb8bb81 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalMap.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalMap.java
@@ -30,20 +30,6 @@ public class FunctionalMap<KeyType, ValueType>
}
/**
- * Create a new functional map wrapping the specified map
- *
- * @param wrap
- * The map to wrap
- */
- public FunctionalMap(Map<KeyType, ValueType> wrap) {
- if (wrap == null) {
- throw new NullPointerException("Map to wrap must not be null");
- }
-
- wrappedMap = wrap;
- }
-
- /**
* Create a new functional map with the specified entries
*
* @param entries
@@ -60,18 +46,48 @@ public class FunctionalMap<KeyType, ValueType>
}
}
+ /**
+ * Create a new functional map wrapping the specified map
+ *
+ * @param wrap
+ * The map to wrap
+ */
+ public FunctionalMap(Map<KeyType, ValueType> wrap) {
+ if (wrap == null) {
+ throw new NullPointerException("Map to wrap must not be null");
+ }
+
+ wrappedMap = wrap;
+ }
+
/*
* (non-Javadoc)
*
- * @see bjc.utils.funcdata.IFunctionalMap#put(K, V)
+ * @see bjc.utils.funcdata.IFunctionalMap#containsKey(K)
*/
@Override
- public ValueType put(KeyType key, ValueType val) {
- if (key == null) {
- throw new NullPointerException("Key must not be null");
- }
+ public boolean containsKey(KeyType key) {
+ return wrappedMap.containsKey(key);
+ }
- return wrappedMap.put(key, val);
+ @Override
+ public IFunctionalMap<KeyType, ValueType> extend() {
+ return new ExtendedMap<>(this, new FunctionalMap<>());
+ }
+
+ @Override
+ public void forEach(BiConsumer<KeyType, ValueType> action) {
+ wrappedMap.forEach(action);
+ }
+
+ @Override
+ public void forEachKey(Consumer<KeyType> action) {
+ wrappedMap.keySet().forEach(action);
+ }
+
+ @Override
+ public void forEachValue(Consumer<ValueType> action) {
+ wrappedMap.values().forEach(action);
}
/*
@@ -93,6 +109,22 @@ public class FunctionalMap<KeyType, ValueType>
return wrappedMap.get(key);
}
+ @Override
+ public int getSize() {
+ return wrappedMap.size();
+ }
+
+ @Override
+ public IFunctionalList<KeyType> keyList() {
+ FunctionalList<KeyType> keys = new FunctionalList<>();
+
+ wrappedMap.keySet().forEach((key) -> {
+ keys.add(key);
+ });
+
+ return keys;
+ }
+
/*
* (non-Javadoc)
*
@@ -112,32 +144,15 @@ public class FunctionalMap<KeyType, ValueType>
/*
* (non-Javadoc)
*
- * @see bjc.utils.funcdata.IFunctionalMap#containsKey(K)
+ * @see bjc.utils.funcdata.IFunctionalMap#put(K, V)
*/
@Override
- public boolean containsKey(KeyType key) {
- return wrappedMap.containsKey(key);
- }
-
- @Override
- public String toString() {
- return wrappedMap.toString();
- }
-
- @Override
- public IFunctionalList<KeyType> keyList() {
- FunctionalList<KeyType> keys = new FunctionalList<>();
-
- wrappedMap.keySet().forEach((key) -> {
- keys.add(key);
- });
-
- return keys;
- }
+ public ValueType put(KeyType key, ValueType val) {
+ if (key == null) {
+ throw new NullPointerException("Key must not be null");
+ }
- @Override
- public void forEach(BiConsumer<KeyType, ValueType> action) {
- wrappedMap.forEach(action);
+ return wrappedMap.put(key, val);
}
@Override
@@ -146,18 +161,8 @@ public class FunctionalMap<KeyType, ValueType>
}
@Override
- public int getSize() {
- return wrappedMap.size();
- }
-
- @Override
- public void forEachKey(Consumer<KeyType> action) {
- wrappedMap.keySet().forEach(action);
- }
-
- @Override
- public void forEachValue(Consumer<ValueType> action) {
- wrappedMap.values().forEach(action);
+ public String toString() {
+ return wrappedMap.toString();
}
@Override
@@ -170,9 +175,4 @@ public class FunctionalMap<KeyType, ValueType>
return values;
}
-
- @Override
- public IFunctionalMap<KeyType, ValueType> extend() {
- return new ExtendedMap<>(this, new FunctionalMap<>());
- }
} \ No newline at end of file
diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalStringTokenizer.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalStringTokenizer.java
index 0e2d199..aa6fca3 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalStringTokenizer.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalStringTokenizer.java
@@ -111,6 +111,15 @@ public class FunctionalStringTokenizer {
}
/**
+ * Check if this tokenizer has more tokens
+ *
+ * @return Whether or not this tokenizer has more tokens
+ */
+ public boolean hasMoreTokens() {
+ return input.hasMoreTokens();
+ }
+
+ /**
* Return the next token from the tokenizer. Returns null if no more
* tokens are available
*
@@ -127,6 +136,15 @@ public class FunctionalStringTokenizer {
}
/**
+ * Convert this tokenizer into a list of strings
+ *
+ * @return This tokenizer, converted into a list of strings
+ */
+ public IFunctionalList<String> toList() {
+ return toList((String element) -> element);
+ }
+
+ /**
* Convert the contents of this tokenizer into a list. Consumes all of
* the input from this tokenizer.
*
@@ -154,22 +172,4 @@ public class FunctionalStringTokenizer {
return returnList;
}
-
- /**
- * Convert this tokenizer into a list of strings
- *
- * @return This tokenizer, converted into a list of strings
- */
- public IFunctionalList<String> toList() {
- return toList((String element) -> element);
- }
-
- /**
- * Check if this tokenizer has more tokens
- *
- * @return Whether or not this tokenizer has more tokens
- */
- public boolean hasMoreTokens() {
- return input.hasMoreTokens();
- }
}
diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/IFunctionalList.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/IFunctionalList.java
index 3358da0..91b2ba3 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/IFunctionalList.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/IFunctionalList.java
@@ -286,6 +286,11 @@ public interface IFunctionalList<ContainedType> {
void removeMatching(ContainedType desiredElement);
/**
+ * Reverse the contents of this list in place
+ */
+ void reverse();
+
+ /**
* Perform a binary search for the specified key using the provided
* means of comparing elements. Since this IS a binary search, the list
* must have been sorted before hand.
@@ -311,6 +316,13 @@ public interface IFunctionalList<ContainedType> {
void sort(Comparator<ContainedType> comparator);
/**
+ * Get the tail of this list (the list without the first element
+ *
+ * @return The list without the first element
+ */
+ public IFunctionalList<ContainedType> tail();
+
+ /**
* Convert this list into an array
*
* @param arrType
@@ -325,16 +337,4 @@ public interface IFunctionalList<ContainedType> {
* @return An iterable view onto the list
*/
Iterable<ContainedType> toIterable();
-
- /**
- * Get the tail of this list (the list without the first element
- *
- * @return The list without the first element
- */
- public IFunctionalList<ContainedType> tail();
-
- /**
- * Reverse the contents of this list in place
- */
- void reverse();
} \ No newline at end of file
diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/IFunctionalMap.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/IFunctionalMap.java
index 0c96a9f..8a54246 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/IFunctionalMap.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/IFunctionalMap.java
@@ -18,21 +18,45 @@ import java.util.function.Function;
public interface IFunctionalMap<KeyType, ValueType> {
/**
- * Add an entry to the map
+ * Check if this map contains the specified key
*
* @param key
- * The key to put the value under
- * @param val
- * The value to add
- * @return The previous value of the key in the map, or null if the key
- * wasn't in the map. However, note that it may also return
- * null if the key was set to null.
+ * The key to check
+ * @return Whether or not the map contains the key
+ */
+ boolean containsKey(KeyType key);
+
+ /**
+ * Extends this map, creating a new map that will delegate queries to
+ * the map, but store any added values itself
*
- * @throws UnsupportedOperationException
- * if the map implementation doesn't support modifying the
- * map
+ * @return An extended map
*/
- ValueType put(KeyType key, ValueType val);
+ IFunctionalMap<KeyType, ValueType> extend();
+
+ /**
+ * Execute an action for each entry in the map
+ *
+ * @param action
+ * the action to execute for each entry in the map
+ */
+ void forEach(BiConsumer<KeyType, ValueType> action);
+
+ /**
+ * Perform an action for each key in the map
+ *
+ * @param action
+ * The action to perform on each key in the map
+ */
+ void forEachKey(Consumer<KeyType> action);
+
+ /**
+ * Perform an action for each value in the map
+ *
+ * @param action
+ * The action to perform on each value in the map
+ */
+ void forEachValue(Consumer<ValueType> action);
/**
* Get the value assigned to the given key
@@ -46,6 +70,20 @@ public interface IFunctionalMap<KeyType, ValueType> {
ValueType get(KeyType key);
/**
+ * Get the number of entries in this map
+ *
+ * @return The number of entries in this map
+ */
+ int getSize();
+
+ /**
+ * Get a list of all the keys in this map
+ *
+ * @return A list of all the keys in this map
+ */
+ IFunctionalList<KeyType> keyList();
+
+ /**
* Transform the values returned by this map.
*
* NOTE: This transform is applied once for each lookup of a value, so
@@ -62,28 +100,21 @@ public interface IFunctionalMap<KeyType, ValueType> {
Function<ValueType, V2> transformer);
/**
- * Check if this map contains the specified key
+ * Add an entry to the map
*
* @param key
- * The key to check
- * @return Whether or not the map contains the key
- */
- boolean containsKey(KeyType key);
-
- /**
- * Get a list of all the keys in this map
- *
- * @return A list of all the keys in this map
- */
- IFunctionalList<KeyType> keyList();
-
- /**
- * Execute an action for each entry in the map
+ * The key to put the value under
+ * @param val
+ * The value to add
+ * @return The previous value of the key in the map, or null if the key
+ * wasn't in the map. However, note that it may also return
+ * null if the key was set to null.
*
- * @param action
- * the action to execute for each entry in the map
+ * @throws UnsupportedOperationException
+ * if the map implementation doesn't support modifying the
+ * map
*/
- void forEach(BiConsumer<KeyType, ValueType> action);
+ ValueType put(KeyType key, ValueType val);
/**
* Remove the value bound to the key
@@ -98,40 +129,9 @@ public interface IFunctionalMap<KeyType, ValueType> {
ValueType remove(KeyType key);
/**
- * Get the number of entries in this map
- *
- * @return The number of entries in this map
- */
- int getSize();
-
- /**
- * Perform an action for each key in the map
- *
- * @param action
- * The action to perform on each key in the map
- */
- void forEachKey(Consumer<KeyType> action);
-
- /**
- * Perform an action for each value in the map
- *
- * @param action
- * The action to perform on each value in the map
- */
- void forEachValue(Consumer<ValueType> action);
-
- /**
* Get a list of the values in this map
*
* @return A list of values in this map
*/
IFunctionalList<ValueType> valueList();
-
- /**
- * Extends this map, creating a new map that will delegate queries to
- * the map, but store any added values itself
- *
- * @return An extended map
- */
- IFunctionalMap<KeyType, ValueType> extend();
} \ No newline at end of file
diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/TransformedValueMap.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/TransformedValueMap.java
index 75557fa..1d52d82 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/TransformedValueMap.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/TransformedValueMap.java
@@ -28,73 +28,73 @@ final class TransformedValueMap<OldKey, OldValue, NewValue>
}
@Override
- public NewValue get(OldKey key) {
- return transformer.apply(mapToTransform.get(key));
+ public boolean containsKey(OldKey key) {
+ return mapToTransform.containsKey(key);
}
@Override
- public boolean containsKey(OldKey key) {
- return mapToTransform.containsKey(key);
+ public IFunctionalMap<OldKey, NewValue> extend() {
+ return new ExtendedMap<>(this, new FunctionalMap<>());
}
@Override
- public String toString() {
- return mapToTransform.toString();
+ public void forEach(BiConsumer<OldKey, NewValue> action) {
+ mapToTransform.forEach((key, val) -> {
+ action.accept(key, transformer.apply(val));
+ });
}
@Override
- public NewValue put(OldKey key, NewValue val) {
- throw new UnsupportedOperationException(
- "Can't add items to transformed map");
+ public void forEachKey(Consumer<OldKey> action) {
+ mapToTransform.forEachKey(action);
}
@Override
- public <MappedValue> IFunctionalMap<OldKey, MappedValue> mapValues(
- Function<NewValue, MappedValue> transform) {
- return new TransformedValueMap<>(this, transform);
+ public void forEachValue(Consumer<NewValue> action) {
+ mapToTransform.forEachValue((val) -> {
+ action.accept(transformer.apply(val));
+ });
}
@Override
- public IFunctionalList<OldKey> keyList() {
- return mapToTransform.keyList();
+ public NewValue get(OldKey key) {
+ return transformer.apply(mapToTransform.get(key));
}
@Override
- public void forEach(BiConsumer<OldKey, NewValue> action) {
- mapToTransform.forEach((key, val) -> {
- action.accept(key, transformer.apply(val));
- });
+ public int getSize() {
+ return mapToTransform.getSize();
}
@Override
- public NewValue remove(OldKey key) {
- return transformer.apply(mapToTransform.remove(key));
+ public IFunctionalList<OldKey> keyList() {
+ return mapToTransform.keyList();
}
@Override
- public int getSize() {
- return mapToTransform.getSize();
+ public <MappedValue> IFunctionalMap<OldKey, MappedValue> mapValues(
+ Function<NewValue, MappedValue> transform) {
+ return new TransformedValueMap<>(this, transform);
}
@Override
- public void forEachKey(Consumer<OldKey> action) {
- mapToTransform.forEachKey(action);
+ public NewValue put(OldKey key, NewValue val) {
+ throw new UnsupportedOperationException(
+ "Can't add items to transformed map");
}
@Override
- public void forEachValue(Consumer<NewValue> action) {
- mapToTransform.forEachValue((val) -> {
- action.accept(transformer.apply(val));
- });
+ public NewValue remove(OldKey key) {
+ return transformer.apply(mapToTransform.remove(key));
}
@Override
- public IFunctionalList<NewValue> valueList() {
- return mapToTransform.valueList().map(transformer);
+ public String toString() {
+ return mapToTransform.toString();
}
@Override
- public IFunctionalMap<OldKey, NewValue> extend() {
- return new ExtendedMap<>(this, new FunctionalMap<>());
+ public IFunctionalList<NewValue> valueList() {
+ return mapToTransform.valueList().map(transformer);
}
} \ No newline at end of file
diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTree.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTree.java
index c147646..712f0e3 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTree.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTree.java
@@ -64,6 +64,23 @@ public class BinarySearchTree<T> {
}
/**
+ * Check if an adjusted pivot falls with the bounds of a list
+ *
+ * @param elements
+ * The list to get bounds from
+ * @param pivot
+ * The pivot
+ * @param pivotAdjustment
+ * The distance from the pivot
+ * @return Whether the adjusted pivot is with the list
+ */
+ private boolean adjustedPivotInBounds(IFunctionalList<T> elements,
+ int pivot, int pivotAdjustment) {
+ return (pivot - pivotAdjustment) >= 0
+ && (pivot + pivotAdjustment) < elements.getSize();
+ }
+
+ /**
* Balance the tree, and remove soft-deleted nodes for free. Takes O(N)
* time, but also O(N) space.
*/
@@ -113,23 +130,6 @@ public class BinarySearchTree<T> {
}
/**
- * Check if an adjusted pivot falls with the bounds of a list
- *
- * @param elements
- * The list to get bounds from
- * @param pivot
- * The pivot
- * @param pivotAdjustment
- * The distance from the pivot
- * @return Whether the adjusted pivot is with the list
- */
- private boolean adjustedPivotInBounds(IFunctionalList<T> elements,
- int pivot, int pivotAdjustment) {
- return (pivot - pivotAdjustment) >= 0
- && (pivot + pivotAdjustment) < elements.getSize();
- }
-
- /**
* Soft-delete a node from the tree. Soft-deleted nodes stay in the
* tree until trim()/balance() is invoked, and are not included in
* traversals/finds.