Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ch8n/datastructurekt
Kotlin Implementation of Datastructure
https://github.com/ch8n/datastructurekt
Last synced: 14 days ago
JSON representation
Kotlin Implementation of Datastructure
- Host: GitHub
- URL: https://github.com/ch8n/datastructurekt
- Owner: ch8n
- Created: 2022-10-25T18:28:51.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-06T07:48:28.000Z (over 1 year ago)
- Last Synced: 2024-10-30T20:13:34.465Z (2 months ago)
- Language: Kotlin
- Homepage:
- Size: 291 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
DataStructure-KT
DataStructure-KT is an open-source project that provides a set of common data structures implemented in Kotlin.
Table of Contents
Features
DataStructure-KT provides the following data structures:
- Stack
- Queue
- Singly Linked List
- Doubly Linked List
- Binary Search Tree
Installation
DataStructure-KT is available on Maven Central. To use it in your project, add the following dependency to your build file:
implementation 'com.github.ch8n.DataStructureKT:linked-list-kt:Version'
Usage
Stack
val stack = Stack()
stack.push(1)
stack.push(2)
stack.push(3)
println(stack.pop()) // Output: 3
Queue
val queue = Queue()
queue.enqueue(1)
queue.enqueue(2)
queue.enqueue(3)
println(queue.dequeue()) // Output: 1
Singly Linked List
val linkedList = SinglyLinkedList()
linkedList.addFirst(1)
linkedList.addLast(2)
linkedList.addLast(3)
println(linkedList.first()) // Output: 1
Doubly Linked List
val linkedList = DoublyLinkedList()
linkedList.addFirst(1)
linkedList.addLast(2)
linkedList.addLast(3)
println(linkedList.last()) // Output: 3
Binary Search Tree
val bst = BinarySearchTree()
bst.insert(5)
bst.insert(3)
bst.insert(7)
bst.insert(1)
bst.insert(4)
bst.insert(6)
bst.insert(8)
println(bst.contains(3)) // Output: true
For more usage examples, check out the tests directory.
Contributing
Contributions are welcome! If you find a bug or have a feature request, please open an issue. If you want to contribute code, please open a pull request.