A comprehensive TypeScript library implementing fundamental data structures and algorithms, inspired by Java's Collections Framework. Built with modern TypeScript practices and comprehensive testing.
This monorepo contains the following packages:
-
@ds-algo/collections
- Collection framework with interfaces and implementations- Core interfaces (Collection, Iterable, Iterator)
- Abstract base classes (planned)
- Concrete implementations (planned)
- Collection-specific algorithms (planned)
-
@ds-algo/algorithms
- Algorithm implementations- Sorting algorithms (Quick Sort, Merge Sort, Bubble Sort, Heap Sort)
- Searching algorithms (Binary Search, Linear Search, Depth First Search)
- Graph algorithms (Dijkstra, BFS, DFS, Topological Sort)
- Dynamic programming solutions (Fibonacci, LCS, Knapsack)
- String algorithms (KMP, Boyer-Moore, Rabin-Karp) - planned
- Mathematical algorithms (GCD, LCM, Prime factorization) - planned
packages/ βββ collections/ # Collection framework β βββ src/ β β βββ interfaces/ # Core interfaces (Collection, Iterable, Iterator) β β βββ abstracts/ # Abstract base classes (planned) β β βββ classes/ # Concrete implementations (planned) β β βββ algorithms/ # Collection-specific algorithms (planned) β βββ tests/ # Test files β βββ README.md # Package documentation βββ algorithms/ # Algorithm implementations βββ src/ β βββ sorting/ # Sorting algorithms (planned) β βββ searching/ # Searching algorithms (planned) β βββ graph/ # Graph algorithms (planned) β βββ dynamic-programming/ # DP solutions (planned) β βββ utils/ # Utility functions (planned) β βββ index.ts # Main exports βββ tests/ # Test files βββ README.md # Package documentation
- Node.js 18+
- pnpm 8+
# Clone the repository git clone https://github.com/your-username/ds-algo.git cd ds-algo # Install dependencies pnpm install # Build all packages pnpm run build # Run tests pnpm run test
import { Collection, Iterable, Iterator } from '@ds-algo/collections'; // Define a custom collection class MyCollection<T> implements Collection<T> { private items: T[] = []; iterator(): Iterator<T> { return new MyIterator(this.items); } } // Use the collection interfaces const collection: Collection<number> = new MyCollection<number>();
import { quickSort, binarySearch, dijkstra } from '@ds-algo/algorithms'; // Sorting const numbers = [64, 34, 25, 12, 22, 11, 90]; const sortedNumbers = quickSort(numbers); // Searching const index = binarySearch(sortedNumbers, 25); // Graph algorithms const graph = { A: { B: 4, C: 2 }, B: { A: 4, C: 1, D: 5 } }; const shortestPaths = dijkstra(graph, 'A');
# Build all packages pnpm run build # Build individual packages pnpm run build --filter @ds-algo/collections pnpm run build --filter @ds-algo/algorithms # Run tests pnpm run test # Run tests for specific package pnpm run test --filter @ds-algo/collections # Development mode with hot reload pnpm run dev # Clean build artifacts pnpm run clean # Format code pnpm run prettier:format # Lint code pnpm run lint
-
Adding New Data Structures (Collections package):
- Create interface in
packages/collections/src/interfaces/
- Create abstract base class in
packages/collections/src/abstracts/
- Create concrete implementation in
packages/collections/src/classes/
- Add tests in
packages/collections/tests/
- Export from
packages/collections/src/index.ts
- Create interface in
-
Adding New Algorithms (Algorithms package):
- Create algorithm file in appropriate category directory
- Export from category's index file
- Add comprehensive JSDoc comments with complexity analysis
- Write unit tests covering various scenarios
- Update package README with usage examples
Each package includes:
- Unit tests with various input sizes
- Edge case testing
- Performance benchmarks
- Type safety verification
- Memory usage analysis
- β Core interfaces implemented (Collection, Iterable, Iterator)
- β Package structure and build configuration
- β TypeScript support with comprehensive type definitions
- π Abstract base classes (in progress)
- π Concrete implementations (planned)
- π Collection-specific algorithms (planned)
- β Package structure and build configuration
- β Comprehensive documentation and roadmap
- π Sorting algorithms (in progress)
- π Searching algorithms (in progress)
- π Graph algorithms (planned)
- π Dynamic programming solutions (planned)
- Type-safe interfaces with full TypeScript support
- Generic collections for any data type
- Iterator pattern for consistent iteration
- Extensible design for custom implementations
- Java-inspired architecture for familiarity
- Well-tested implementations with comprehensive test coverage
- Performance optimized with complexity analysis
- Multiple algorithm categories (sorting, searching, graph, etc.)
- TypeScript-first with proper type definitions
- Educational focus with clear documentation
- Collections Package - Collection framework documentation
- Algorithms Package - Algorithms library documentation
- API Reference - Complete API documentation (planned)
- Performance Benchmarks - Algorithm performance comparisons (planned)
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Make your changes with proper tests
- Ensure all tests pass (
pnpm run test
) - Submit a pull request
- Follow TypeScript best practices
- Write comprehensive tests for new features
- Include JSDoc comments for all public APIs
- Update relevant documentation
- Ensure code formatting with Prettier
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by Java's Collections Framework
- Built with modern TypeScript practices
- Comprehensive testing with Vitest
- Monorepo management with pnpm workspaces
- Implement core collection classes (ArrayList, LinkedList, HashSet)
- Add basic sorting algorithms (Quick Sort, Merge Sort)
- Add searching algorithms (Binary Search, Linear Search)
- Add comprehensive test coverage
- Add performance benchmarks
- Add graph algorithms (Dijkstra, BFS, DFS)
- Add dynamic programming solutions
- Add string algorithms
- Add mathematical algorithms
- Add algorithm visualization tools
- Add advanced data structures (B-trees, Red-black trees)
- Add parallel algorithms
- Add machine learning algorithms
- Add comprehensive documentation site
- Add interactive examples and demos
- TypeScript Collections - Alternative TypeScript collections library
- Algorithms.js - JavaScript algorithms and data structures
- Data Structures and Algorithms in TypeScript - DSA implementation in TypeScript
Note: This is an active development project. Check the Issues page for current development status and planned features.