Skip to content

Implemented most useful and important Data Structures used in Software Development, All With TypeScript ๐ŸŒŸ

License

Notifications You must be signed in to change notification settings

AliSawari/ts-data-structure

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

74 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Data Structure and Algorithms - TypeScript Build & Test

Implemented most useful and important Data Structures used in Software Development, All With TypeScript ๐ŸŒŸ

Table of Contents

List of Implemented Data Structures

  • Linked Lists
    1. Simple Linked List
    2. Doubly Linked Lists
  • Stacks
  • Queues
  • Trees

Data Structure with TypeScript

the benefits of using the Type system from TypeScript is the ability to create new types alongside the class definitions, which allows you to implement the Data Structure types easily and correctly.

I've tried to be as close as possible to the real use cases of Data Structures in Real life and in the classic definitions.

Examples

here's a quick type definition of Linked List.

type LinkedListType = {
  length: number;
  head: NodeType | null;
  tail: NodeType | null;
  push?(value: any): LinkedListType;
  pop?(): NodeType | unknown;
  shift?(): NodeType | unknown;
  unshift?(value: any): LinkedListType;
  get?(index: number): NodeType | unknown;
  set?(index: number, value: any): boolean;
  insert?(index: number, value: any): void;
  remove?(value: any): NodeType | unknown;
  reverse?(): void;
  log?(): void;
};

you can see that each property or method has a declared type. the value of a linked list however can be different, thats why any would make sense. A Generic type will be implemented soon.

Run

You can run the example and testing files with this command:

npm run examples

To compile the project, simply run:

npm run build

Testing

Run tests with npm test.

Each Test file is related to one data structure(each file for subgroups) the goal of the unit testing files is to assert the correctness of the implemented Data Structure. you can find tests in the tests Directory.

License

This repo is under MIT License

Happy Hacking ๐Ÿฅท

About

Implemented most useful and important Data Structures used in Software Development, All With TypeScript ๐ŸŒŸ

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published