Skip to content

Commit

Permalink
Javadoc clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
phishman3579 committed Jul 3, 2017
1 parent eb56f0e commit e7fa878
Show file tree
Hide file tree
Showing 106 changed files with 731 additions and 596 deletions.
6 changes: 3 additions & 3 deletions src/com/jwetherell/algorithms/data_structures/AVLTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
* trees are more rigidly balanced, they are faster than red-black trees for
* lookup intensive applications. However, red-black trees are faster for
* insertion and removal.
*
* http://en.wikipedia.org/wiki/AVL_tree
*
* <p>
* @see <a href="https://en.wikipedia.org/wiki/AVL_tree">AVL Tree (Wikipedia)</a>
* <br>
* @author Justin Wetherell <[email protected]>
*/
public class AVLTree<T extends Comparable<T>> extends BinarySearchTree<T> {
Expand Down
6 changes: 3 additions & 3 deletions src/com/jwetherell/algorithms/data_structures/BTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* two children. Unlike self-balancing binary search trees, the B-tree is
* optimized for systems that read and write large blocks of data. It is
* commonly used in databases and file-systems.
*
* http://en.wikipedia.org/wiki/B-tree
*
* <p>
* @see <a href="https://en.wikipedia.org/wiki/B-tree">B-Tree (Wikipedia)</a>
* <br>
* @author Justin Wetherell <[email protected]>
*/
@SuppressWarnings("unchecked")
Expand Down
6 changes: 3 additions & 3 deletions src/com/jwetherell/algorithms/data_structures/BinaryHeap.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
* the tree is not complete, the nodes of that level are filled from left to
* right. 2) The heap property: each node is right than or equal to each of its
* children according to a comparison predicate defined for the data structure.
*
* http://en.wikipedia.org/wiki/Binary_heap
*
* <p>
* @see <a href="https://en.wikipedia.org/wiki/Binary_heap">Binary Heap (Wikipedia)</a>
* <br>
* @author Justin Wetherell <[email protected]>
*/
@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
* keys less than the node's key. 2) The right subtree of a node contains only
* nodes with keys greater than the node's key. 3) Both the left and right
* subtrees must also be binary search trees.
*
* http://en.wikipedia.org/wiki/Binary_search_tree
*
* <p>
* @see <a href="https://en.wikipedia.org/wiki/Binary_search_tree">Binary Search Tree (Wikipedia)</a>
* <br>
* @author Justin Wetherell <[email protected]>
*/
@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
* string in a way that allows for a particularly fast implementation of many
* important string operations. This implementation is based upon a patricia
* trie which IS a compact trie.
*
* http://en.wikipedia.org/wiki/Suffix_trie
*
* <p>
* @see <a href="https://en.wikipedia.org/wiki/Suffix_trie">Suffix Trie (Wikipedia)</a>
* <br>
* @author Justin Wetherell <[email protected]>
*/
@SuppressWarnings("unchecked")
Expand Down
14 changes: 7 additions & 7 deletions src/com/jwetherell/algorithms/data_structures/DisjointSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
/**
* In computer science, a disjoint-set data structure, also called a union–find data structure or merge–find set, is a data structure that keeps track of a set of
* elements partitioned into a number of disjoint (non-overlapping) subsets.
*
* It supports two useful operations:
* <p>
* It supports two useful operations:<br>
* Find: Determine which subset a particular element is in. Find typically returns an item from this set that serves as its "representative"; by comparing the
* result of two Find operations, one can determine whether two elements are in the same subset.
* Union: Join two subsets into a single subset.
*
* http://en.wikipedia.org/wiki/Disjoint-set_data_structure
*
* result of two Find operations, one can determine whether two elements are in the same subset.<br>
* Union: Join two subsets into a single subset.<br>
* <p>
* @see <a href="https://en.wikipedia.org/wiki/Disjoint-set_data_structure">Disjoint Set (Wikipedia)</a>
* <br>
* @author Justin Wetherell <[email protected]>
*/
@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
* for calculation and manipulation of the prefix sums of a table of values. Fenwick trees
* primarily solve the problem of balancing prefix sum calculation efficiency with element
* modification efficiency.
*
* http://en.wikipedia.org/wiki/Fenwick_tree
*
* <p>
* This class is meant to be somewhat generic, all you'd have to do is extend
* the Data abstract class to store your custom data. I've included a range sum
* implementations.
*
* <p>
* @see <a href="https://en.wikipedia.org/wiki/Fenwick_tree">Fenwick Tree (Wikipedia)</a>
* <br>
* @author Justin Wetherell <[email protected]>
*/
@SuppressWarnings("unchecked")
Expand Down
6 changes: 3 additions & 3 deletions src/com/jwetherell/algorithms/data_structures/Graph.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
* Graph. Could be directed or undirected depending on the TYPE enum. A graph is
* an abstract representation of a set of objects where some pairs of the
* objects are connected by links.
*
* http://en.wikipedia.org/wiki/Graph_(mathematics)
*
* <p>
* @see <a href="https://en.wikipedia.org/wiki/Graph_(mathematics)">Graph (Wikipedia)</a>
* <br>
* @author Justin Wetherell <[email protected]>
*/
@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
* A hash array mapped trie (HAMT) is an implementation of an associative
* array that combines the characteristics of a hash table and an array mapped
* trie. It is a refined version of the more general notion of a hash tree.
*
* <p>
* This implementation is 32-bit and steps in 5-bit intervals, maximum tree
* height of 7.
*
* http://en.wikipedia.org/wiki/Hash_array_mapped_trie
*
* <p>
* @see <a href="https://en.wikipedia.org/wiki/Hash_array_mapped_trie">Hash Array Mapped Trie (Wikipedia)</a>
* <br>
* @author Justin Wetherell <[email protected]>
*/
@SuppressWarnings("unchecked")
Expand Down
6 changes: 3 additions & 3 deletions src/com/jwetherell/algorithms/data_structures/HashMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* Hash Map using either chaining or probing. hash map is a data structure that
* uses a hash function to map identifying values, known as keys, to their
* associated values.
*
* http://en.wikipedia.org/wiki/Hash_table
*
* <p>
* @see <a href="https://en.wikipedia.org/wiki/Hash_table">Hash Map/Table (Wikipedia)</a>
* <br>
* @author Justin Wetherell <[email protected]>
*/
@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
/**
* A Treap is a self-balancing binary search tree that uses randomization to maintain
* a low height. In this version, it is used emulate the operations of an array and linked list.
*
* <p>
* Time Complexity: Assuming the join/merge functions have constant complexity.
* add(value), add(index,value), remove(index), set(index,value), get(index) all have O(log N).
* remove(value), get(value), contains(value) all have O(N).
*
* <p>
* Space Complexity: O(N)
*
* <p>
* Note: This implementation is 0-based, meaning that all
* indices from 0 to size() - 1, inclusive, are accessible.
*
* http://en.wikipedia.org/wiki/Treap
*
* <p>
* @see <a href="https://en.wikipedia.org/wiki/Treap">Treap (Wikipedia)</a>
* <br>
* @author Justin Wetherell <[email protected]>
*/
@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
* An interval tree is an ordered tree data structure to hold intervals.
* Specifically, it allows one to efficiently find all intervals that overlap
* with any given interval or point.
*
* http://en.wikipedia.org/wiki/Interval_tree
*
* <p>
* @see <a href="https://en.wikipedia.org/wiki/Interval_tree">Interval Tree (Wikipedia)</a>
* <br>
* @author Justin Wetherell <[email protected]>
*/
public class IntervalTree<O extends Object> {
Expand Down
3 changes: 2 additions & 1 deletion src/com/jwetherell/algorithms/data_structures/KdTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
* useful data structure for several applications, such as searches involving a
* multidimensional search key (e.g. range searches and nearest neighbor
* searches). k-d trees are a special case of binary space partitioning trees.
* <p>
* @see <a href="https://en.wikipedia.org/wiki/K-d_tree">K-D Tree (Wikipedia)</a>
* <br>
* @author Justin Wetherell <[email protected]>
* @see <a href="http://en.wikipedia.org/wiki/K-d_tree">K-d_tree (Wikipedia)</a>
*/
public class KdTree<T extends KdTree.XYZPoint> implements Iterable<T> {

Expand Down
45 changes: 23 additions & 22 deletions src/com/jwetherell/algorithms/data_structures/LCPArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,33 @@
* data structure to the suffix array. It stores the lengths of the longest common
* prefixes (LCPs) between all pairs of consecutive suffixes in a sorted suffix array.
* <p>
* https://en.wikipedia.org/wiki/LCP_array
* @see <a href="https://en.wikipedia.org/wiki/LCP_array">LCP Array (Wikipedia)</a>
* <br>
* @author Jakub Szarawarski <[email protected]>
* @author Justin Wetherell <[email protected]>
*/
public class LCPArray {
public class LCPArray<C extends CharSequence> {

private static final char DEFAULT_END_SEQ_CHAR = '$';

private char END_SEQ_CHAR;
private SuffixArray suffixArrayBuilder;
private ArrayList<Integer> LCP;
private final char endSeqChar;

public LCPArray(CharSequence sequence){
private SuffixArray suffixArray;
private ArrayList<Integer> lcp;

public LCPArray(C sequence){
this(sequence, DEFAULT_END_SEQ_CHAR);
}

public LCPArray(CharSequence sequence, char endChar) {
END_SEQ_CHAR = endChar;
suffixArrayBuilder = new SuffixArray(sequence, END_SEQ_CHAR);
public LCPArray(C sequence, char endChar) {
endSeqChar = endChar;
suffixArray = new SuffixArray(sequence, endSeqChar);
}

public ArrayList<Integer> getLCPArray() {
if (LCP == null)
if (lcp == null)
LCPAlgorithm();
return LCP;
return lcp;
}

private void LCPAlgorithm() {
Expand All @@ -41,20 +42,20 @@ private void LCPAlgorithm() {
}

private ArrayList<Integer> getLCPR() {
final ArrayList<Integer> KMRArray = suffixArrayBuilder.getKMRarray();
final ArrayList<Integer> suffixArray = suffixArrayBuilder.getSuffixArray();
final String string = suffixArrayBuilder.getString();
final int length = KMRArray.size();
final ArrayList<Integer> KMRArrayList = suffixArray.getKMRarray();
final ArrayList<Integer> suffixArrayList = suffixArray.getSuffixArray();
final String string = suffixArray.getString();
final int length = KMRArrayList.size();
final ArrayList<Integer> LCPR = new ArrayList<Integer>(); // helper array, LCP[i] = LCPR[suffixArray[i]]

int startingValue = 0;
for (int i=0; i<length; i++) {
if(KMRArray.get(i).equals(0)) {
if(KMRArrayList.get(i).equals(0)) {
LCPR.add(0);
startingValue = 0;
} else {
int LCPRValue = startingValue;
final int predecessor = suffixArray.get(KMRArray.get(i)-1);
final int predecessor = suffixArrayList.get(KMRArrayList.get(i)-1);
while (string.charAt(i+LCPRValue) == string.charAt(predecessor+LCPRValue))
LCPRValue++;
LCPR.add(LCPRValue);
Expand All @@ -66,12 +67,12 @@ private ArrayList<Integer> getLCPR() {
}

private void getLCPfromLCPR(ArrayList<Integer> LCPR) {
final ArrayList<Integer> suffixArray = suffixArrayBuilder.getSuffixArray();
final int length = suffixArray.size();
final ArrayList<Integer> suffixArrayList = suffixArray.getSuffixArray();
final int length = suffixArrayList.size();

LCP = new ArrayList<Integer>();
LCP.add(null); //no value for LCP[0]
lcp = new ArrayList<Integer>();
lcp.add(null); //no value for LCP[0]
for (int i=1; i<length; i++)
LCP.add(LCPR.get(suffixArray.get(i)));
lcp.add(LCPR.get(suffixArrayList.get(i)));
}
}
32 changes: 20 additions & 12 deletions src/com/jwetherell/algorithms/data_structures/List.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,24 @@

import com.jwetherell.algorithms.data_structures.interfaces.IList;

/**
* In mathematics, a sequence is an enumerated collection of objects in which repetitions are allowed. Like a set, it contains members (also called elements, or terms). The number of elements
* (possibly infinite) is called the length of the sequence. Unlike a set, order matters, and exactly the same elements can appear multiple times at different positions in the sequence.
* <p>
* @see <a href="https://en.wikipedia.org/wiki/Sequence">Sequence (Wikipedia)</a>
* <br>
* @author Justin Wetherell <[email protected]>
*/
@SuppressWarnings("unchecked")
public abstract class List<T> implements IList<T> {

/**
* A dynamic array, growable array, resizable array, dynamic table, or array
* list is a random access, variable-size list data structure that allows
* elements to be added or removed.
*
* http://en.wikipedia.org/wiki/Dynamic_array
*
* <p>
* @see <a href="https://en.wikipedia.org/wiki/Dynamic_array">Dynamic Array (Wikipedia)</a>
* <br>
* @author Justin Wetherell <[email protected]>
*/
public static class ArrayList<T> extends List<T> {
Expand Down Expand Up @@ -280,9 +288,9 @@ public T set(int index, T value) {
/**
* Linked List (Singly link). A linked list is a data structure consisting
* of a group of nodes which together represent a sequence.
*
* http://en.wikipedia.org/wiki/Linked_list
*
* <p>
* @see <a href="https://en.wikipedia.org/wiki/Linked_list">Linked List (Wikipedia)</a>
* <br>
* @author Justin Wetherell <[email protected]>
*/
public static class SinglyLinkedList<T> extends List<T> {
Expand Down Expand Up @@ -477,9 +485,9 @@ public String toString() {
/**
* Linked List (singly link). A linked list is a data structure consisting
* of a group of nodes which together represent a sequence.
*
* http://en.wikipedia.org/wiki/Linked_list
*
* <p>
* @see <a href="https://en.wikipedia.org/wiki/Linked_list">Linked List (Wikipedia)</a>
* <br>
* @author Justin Wetherell <[email protected]>
*/
public static class JavaCompatibleSinglyLinkedList<T> extends java.util.AbstractSequentialList<T> {
Expand Down Expand Up @@ -688,9 +696,9 @@ public T previous() {
/**
* Linked List (doubly link). A linked list is a data structure consisting
* of a group of nodes which together represent a sequence.
*
* http://en.wikipedia.org/wiki/Linked_list
*
* <p>
* @see <a href="https://en.wikipedia.org/wiki/Linked_list">Linked List (Wikipedia)</a>
* <br>
* @author Justin Wetherell <[email protected]>
*/
public static class DoublyLinkedList<T> extends List<T> {
Expand Down
6 changes: 3 additions & 3 deletions src/com/jwetherell/algorithms/data_structures/Matrix.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
/**
* Matrx. This Matrix implementation is designed to be more efficient
* in cache. A matrix is a rectangular array of numbers, symbols, or expressions.
*
* http://en.wikipedia.org/wiki/Matrix_(mathematics)
*
* <p>
* @see <a href="https://en.wikipedia.org/wiki/Matrix_(mathematics)">Matrix (Wikipedia)</a>
* <br>
* @author Justin Wetherell <[email protected]>
*/
@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* non-terminating (black) node with only one child is merged with its child.
* The result is that every internal non-terminating (black) node has at least
* two children. Each terminating node (white) represents the end of a string.
*
* http://en.wikipedia.org/wiki/Radix_tree
*
* <p>
* @see <a href="https://en.wikipedia.org/wiki/Radix_tree">Radix Tree / Patricia Trie (Wikipedia)</a>
* <br>
* @author Justin Wetherell <[email protected]>
*/
@SuppressWarnings("unchecked")
Expand Down
6 changes: 3 additions & 3 deletions src/com/jwetherell/algorithms/data_structures/QuadTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
* A quadtree is a tree data structure in which each internal node has exactly four children. Quadtrees
* are most often used to partition a two dimensional space by recursively subdividing it into four
* quadrants or regions. The regions may be square or rectangular, or may have arbitrary shapes.
*
* http://en.wikipedia.org/wiki/Quadtree
*
* <p>
* @see <a href="https://en.wikipedia.org/wiki/Quadtree">QuadTree (Wikipedia)</a>
* <br>
* @author Justin Wetherell <[email protected]>
*/
@SuppressWarnings("unchecked")
Expand Down
Loading

0 comments on commit e7fa878

Please sign in to comment.