Skip to content

ayoubMah/mycollections

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

My Custom Java Collections Library

A personal project to build core Java data structures from scratch, to deeply understand DSA and Java internals.


Purpose

This library re-implements popular collections like arrays, ArrayList, LinkedList, Stack, Queue, HashMap, Set, Tree, Heap, and more — from scratch. It’s designed for learning, practicing clean code, and building stuff.


Phase 0 — Raw Arrays

✅ RawIntArray

  • add(value)
  • addAt(index, value)
  • removeAt(index)
  • remove(value)
  • find(value)
  • findBinary(value)
  • indexOf(value)
  • contains(value)
  • get(index)
  • set(index, value)
  • len()
  • isEmpty()
  • clear()
  • display()
  • bubbleSort()
  • selectionSort()
  • insertionSort()
  • max()
  • Unit Tests ✅

Phase 1 — Lists

✅ MyArrayList

  • add(value)
  • display()
  • addAt(index, value)
  • removeAt(index)
  • remove(value)
  • removeAll(value)
  • find(value)
  • indexOf(value)
  • contains(value)
  • get(index)
  • set(index, value)
  • size()
  • isEmpty()
  • clear()
  • toArray()
  • iterator()

✅ MyLinkedList

  • add(value)
  • addFirst(value)
  • addLast(value)
  • remove(value)
  • removeFirst()
  • removeLast()
  • find(value)
  • indexOf(value)
  • contains(value)
  • get(index)
  • set(index, value)
  • count()
  • isEmpty()
  • clear()
  • iterator()

Phase 2 — Linear Structures

✅ MyStack

  • push(value)
  • pop()
  • peek()
  • isEmpty()
  • count()
  • clear()

✅ MyQueue

  • enqueue(value)
  • dequeue()
  • peek()
  • isEmpty()
  • count()
  • clear()

✅ MyDeque

  • addFirst(value)
  • addLast(value)
  • removeFirst()
  • removeLast()
  • peekFirst()
  • peekLast()
  • isEmpty()
  • count()
  • clear()

Phase 3 — Map & Set

✅ MyHashMap<K,V>

  • add(key, value)
  • get(key)
  • remove(key)
  • containsKey(key)
  • containsValue(value)
  • keys()
  • values()
  • count()
  • isEmpty()
  • clear()

✅ MyHashSet

  • add(value)
  • remove(value)
  • contains(value)
  • count()
  • isEmpty()
  • clear()

Phase 4 — Trees & Heaps

✅ MyBinarySearchTree

  • add(value)
  • remove(value)
  • find(value)
  • contains(value)
  • traverseInOrder()
  • traversePreOrder()
  • traversePostOrder()
  • getMin()
  • getMax()
  • count()
  • isEmpty()
  • clear()

✅ MyPriorityQueue (Heap)

  • add(value)
  • poll()
  • peek()
  • isEmpty()
  • count()
  • clear()

Phase 5 — Infrastructure

  • Make all collections generic <T> or <K,V>
  • Implement Iterable<T> where needed
  • Add proper exceptions (IndexOutOfBoundsException, etc.)
  • Add JUnit tests for all
  • Add JavaDocs for all classes & methods
  • Make nice CLI banner (✅ already started!)
  • Example main() for each structure

Future Ideas

  • AVL Tree or Red-Black Tree
  • LRU Cache
  • Thread-safe collections
  • Serialization support
  • Publish as a Maven/Gradle artifact
  • Performance benchmarks vs. java.util

💡 How to Use

Clone the repo and run your CLI banner:

javac -d out src/**/*.java
java MyCollectionsApp

📜 License

This project is licensed under the MIT License — see the LICENSE file for details.


✍️ Author

Ayoub El-mahjouby GitHub Profile

About

My Custom Java Collections Library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages