Skip to content

Commit 6f17c43

Browse files
committed
refactor(Collections): improve ArrayList and LinkedList implementations
This commit enhances both ArrayList and LinkedList classes to provide better key handling, consistent exception throwing, and support for mixed key types. It improves type safety, performance, and API consistency. ArrayList changes: - Add isValidArrayKey method for key validation (int or string) - Update set method to throw exceptions for invalid keys and out-of-range indices - Modify hasKey method to use isValidArrayKey and array_key_exists - Update get method to use the new hasKey implementation - Add keyToString method for better error messages - Simplify contains method using in_array for better performance LinkedList changes: - Modify set and get methods to support mixed key types - Implement findNode method to locate nodes by index or value - Add compareValues method for flexible element comparison - Update exception messages to include key information - Ensure consistent behavior between numeric and non-numeric keys General: - Update method signatures to use mixed type consistently across both classes - Improve code comments and method descriptions
1 parent 8cc515e commit 6f17c43

File tree

5 files changed

+6227
-6168
lines changed

5 files changed

+6227
-6168
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Initial configurations
2-
PHP_SERVICE := kariricode-contract
2+
PHP_SERVICE := kariricode-data-structure
33
DC := docker-compose
44

55
# Command to execute commands inside the PHP container

0 commit comments

Comments
 (0)