Skip to content

refactor(Collections): improve ArrayList and LinkedList implementations #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 10, 2024

Conversation

walmir-silva
Copy link
Contributor

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

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
@walmir-silva walmir-silva merged commit 91c9e7e into main Oct 10, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant