Collection of implemented data structures and algorithms in Java, some C++, Python, TypeScript, Go, and Rust, as well as multithreading examples in Java.
- For the Java examples, these are not exact copies of the Java Collections Framework, since there is no such thing as an ArrayQueue (rather, there is the ArrayDeque), LinkedList is slightly different (doubly-linked, for one), both of which implement the Deque interface, and the hash codes are defined differently
- There are also no NavigableMap/NavigableSet, SortedMap/SortedSet, or SequencedMap/SequencedSet interfaces, etc.
The multithreading examples were taken from https://www.youtube.com/watch?v=d9s_d28yJq0&list=PLfqABt5AS4FmuQf70psXrsMLEDQXNkLq2
Note: before building documentation or generating code coverage for the Python code, run
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
- This creates a Python virtual environment, which indicates that all non-standard Python dependencies specific to this project be stored in the
.venv
folder, uses this folder as the default Python environment, and proceeds to download the dependencies inrequirements.txt
to it requirements.in
contains the direct non-standard dependencies, whereasrequirements.txt
, which is updated withpip-compile
, contains all (direct and transitive) non-standard dependencies- To leave this virtual environment, simply run
deactivate
- Other Python projects use build which use
pyproject.toml
files - Add a Python dependency by running
pip install <package>
and add it torequirements.in
Likewise for Java, run
./installj.sh
- A real-world Java project would use something like Maven and conform to its requirements
For TypeScript, run
npm install
- The TypeScript analog to the Python
.venv
folder is callednode_modules
- TypeScript non-standard direct dependencies are listed in
package.json
, whereas all (direct and transitive) dependencies are located inpackage-lock.json
, which is updated withnpm update
- Add a TypeScript dependency by running
npm install -D <package>
- Even though this repository uses Jest, Node.js has it's own built-in testing framework
For Go, run
echo "export PATH=$HOME/go/bin:$PATH" >> ~/.bashrc
source ~/.bashrc
go install golang.org/x/pkgsite/cmd/pkgsite@latest
go work use
go install <url-to-project>
compiles and installs a Go package- This can also be used to install a local Go project by simply running
go install
- Binaries are located in
~/go/bin/
- This can also be used to install a local Go project by simply running
- The specific versions of non-standard dependencies for a Go package are listed in the package's
go.mod
file - The hashes of those dependencies are listed in
go.sum
- By convention, Go unit test files are located in the same folder as the source files
To add a Go dependency in a Go module:
- Run
go get <url-to-dependency>
, which downloads the dependency and installs it to~/go/pkg/
- Example:
go get rsc.io/quote/v4
- Example:
- Add the import and use the dependency in your project
- Example:
package main import "fmt" import "rsc.io/quote/v4" func main() { fmt.Println(quote.Go()) }
- Example:
- Run
go mod tidy
, which reorganizes thego.mod
andgo.sum
files
For Rust, run
echo "export PATH=$HOME/.cargo/bin:$PATH" >> ~/.bashrc
source ~/.bashrc
cargo fetch
- By convention, Rust unit tests are in the same file as the corresponding source code
cargo install --path .
installs the local package in~/.cargo/bin
- Add a Rust dependency by running
cargo add <package>