-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit df80c1d
Showing
6 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Dirs | ||
build/ | ||
|
||
*.class | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.ear | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2016-present, Rui Afonso Pereira | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# String Matching -- Data Structures | ||
|
||
## Getting started | ||
|
||
### Prerequisites | ||
|
||
The following dependencies must be installed on your machine: | ||
|
||
* Java | ||
* [Ant](http://ant.apache.org/) | ||
|
||
### Running tests | ||
|
||
$ ant test | ||
|
||
## License | ||
|
||
Code released under the [MIT license](./LICENSE). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<project name="junit-example"> | ||
<property name="main.build.dir" value="build/main"/> | ||
<property name="main.src.dir" value="src/main/java"/> | ||
<property name="test.build.dir" value="build/test"/> | ||
<property name="test.src.dir" value="src/test/java"/> | ||
|
||
<path id="classpath.test"> | ||
<pathelement location="lib/junit-4.12.jar"/> | ||
<pathelement location="lib/hamcrest-core-1.3.jar"/> | ||
<pathelement location="${main.build.dir}"/> | ||
</path> | ||
|
||
<target name="compile"> | ||
<mkdir dir="${main.build.dir}"/> | ||
<javac srcdir="${main.src.dir}" destdir="${main.build.dir}" includeantruntime="false"/> | ||
</target> | ||
|
||
<target name="test-compile" depends="compile"> | ||
<mkdir dir="${test.build.dir}"/> | ||
<javac srcdir="${test.src.dir}" destdir="${test.build.dir}" includeantruntime="false"> | ||
<classpath refid="classpath.test"/> | ||
</javac> | ||
</target> | ||
|
||
<target name="test" depends="test-compile"> | ||
<junit printsummary="on" haltonfailure="yes" fork="true"> | ||
<classpath> | ||
<path refid="classpath.test"/> | ||
<pathelement location="${test.build.dir}"/> | ||
</classpath> | ||
<formatter type="brief" usefile="false" /> | ||
<batchtest> | ||
<fileset dir="${test.src.dir}" includes="**/*Test.java" /> | ||
</batchtest> | ||
</junit> | ||
</target> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
public class TrieST<Value> { | ||
|
||
/* | ||
* Extendeed ASCII | ||
*/ | ||
private static int R = 256; | ||
|
||
/* | ||
* The root of the trie | ||
*/ | ||
private Node root; | ||
|
||
/* | ||
* The number of keys in this trie | ||
*/ | ||
private int size; | ||
|
||
/* | ||
* R-way trie node | ||
*/ | ||
private static class Node { | ||
private Object value; | ||
private Node[] next = new Node[R]; | ||
} | ||
|
||
/** | ||
* Initializes an empty string symbol table. | ||
*/ | ||
public TrieST() { } | ||
|
||
public int size() { | ||
return 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import static org.junit.Assert.assertEquals; | ||
import org.junit.Test; | ||
|
||
public class TrieSTTest { | ||
|
||
@Test | ||
public void size() { | ||
TrieST<Integer> st = new TrieST<Integer>(); | ||
assertEquals(0, st.size()); | ||
} | ||
} |