Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lccodder/linkedlist-ts
Default linked list implementation written on TypeScript
https://github.com/lccodder/linkedlist-ts
data-structures linked-list typescript
Last synced: 3 days ago
JSON representation
Default linked list implementation written on TypeScript
- Host: GitHub
- URL: https://github.com/lccodder/linkedlist-ts
- Owner: LCcodder
- License: gpl-3.0
- Created: 2023-10-10T21:16:26.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-11-05T21:39:41.000Z (about 1 year ago)
- Last Synced: 2024-11-26T12:13:20.154Z (2 months ago)
- Topics: data-structures, linked-list, typescript
- Language: TypeScript
- Homepage:
- Size: 19.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Static/dynamic typed Linked List realization on TypeScript
### **Simple D/S realization made with TS. Includes only base Linked List methods such as `append`, `prepend`, `to array`, etc**
___
## *Node structure:*
```Typescript
interface ListNode > {
value: TVal,
next: ListNode | null
}
```
* Generic type completion `TVal` extends `any` type w/o `undefined`, `never` and `null` in order to avoid unrealistic value use cases
## `IList` *interface:*
```TypeScript
interface IList {
getHead(): ListNode | null,
getTail(): ListNode | null,
addToTail(dataset: TVal): void,
addToHead(dataset: TVal): void,
toArray(callback?: (array: Array) => void): Array,
replace(oldValue: TVal, newValue: TVal, instancesCount?: number, callback?: (replacedNode: ListNode) => void ): number,
remove(value: TVal, instancesCount?: number, callback?: (removedNode: ListNode) => void ): number
}
```## **Can be used with fixed type of value or each-node-changing type:**
### Dynamic implementation:
```TypeScript
let ll = new LinkedList.List()
ll.addToTail({prop: "str"})
ll.addToTail(10)
ll.addToHead("string")
```
### Static implementation:
```TypeScript
let ll = new LinkedList.List()
ll.addToTail(1)
ll.addToTail(10)
ll.addToHead(100)
```
---
## Dependencies:
+ `typescript` (save-dev): `^5.2.2`
+ `node`: `v18.17.1`