-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Home
This repository is contribution friendly 😃. If you're a data structures enthusiast (like me!) and want to add or improve a data structure your contribution is welcome! Please be sure to include tests 😘
This project uses Gradle as a build system (and testing). Make sure you have Java 8+ SDK installed and the gradle command-line tool. Run the build command to make sure you don't get any errors:
Algorithms$ gradle build
The procedure to add a new data structure named Foo is the following:
- Create a new folder called Foo in com/williamfiset/datastructures/Foo
- Add the data structure implementation for Foo in com/williamfiset/datastrutures/Foo/Foo.java
- Add tests for Foo in javatests/com/williamfiset/datastrutures/Foo/FooTest.java 😘
- Edit the build.gradle file and add Foo to the project.
- Run
gradle goJF
to format your Java code. - Send pull request for review 😮
This repository places a large emphasis on good testing practice to ensure that published data structures are bug free and high quality. Testing is done using a combinations of frameworks including: JUnit, Mockito and the Google Truth framework, but mostly JUnit.
When developing you likely do not want to run all tests but only a subset of them. For example, if you want to run the LinkedListTest.java file under javatests/com/williamfiset/datastructures/linkedlist/LinkedListTest.java you can execute:
data-structures$ gradle test --tests "javatests.com.williamfiset.datastructures.linkedlist.LinkedListTest"
Sometimes there are many test files for one data structure. One example is the 🌲FenwickTree🌲 which currently has two test files: FenwickTreeRangeQueryPointUpdateTest.java and FenwickTreeRangeUpdatePointQueryTest.java, in which case you can specify a glob expression to capture all the appropriate test files:
gradle test --tests "javatests.com.williamfiset.datastructures.fenwicktree.FenwickTree*Test"