Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Sep 13, 2025

Summary

This PR addresses issue #53 by making the Count method an optimization rather than a basic method. The solution provides a default implementation in the ILinks interface that uses the Each method to count links.

Changes Made

  • Added default implementation: The Count method now has a default implementation in the interface that uses the Each method to count matching links
  • Added documentation: Added remarks explaining that this is an optimization method that can be overridden for better performance
  • Preserved compatibility: All existing code continues to work without changes

Technical Details

The default implementation:

TLinkAddress Count(IList<TLinkAddress>? restriction)
{
    var counter = TLinkAddress.Zero;
    Each(restriction, link =>
    {
        counter++;
        return Constants.Continue;
    });
    return counter;
}

This approach allows:

  1. Basic functionality: Works out of the box for any implementation that provides Each
  2. Optimization opportunity: Implementations can override this method with more efficient counting mechanisms
  3. Backward compatibility: All existing code continues to work

Testing

  • All existing tests pass ✅
  • Build completes successfully ✅
  • No breaking changes introduced ✅

Related

Fixes #53

🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #53
@konard konard self-assigned this Sep 13, 2025
The Count method is now a default implementation in the ILinks interface
that uses the Each method to count links. This makes Count an optimization
rather than a basic method, as it can be overridden by implementations
that have more efficient counting mechanisms.

- Added default implementation of Count method using Each
- Added documentation remarks explaining it's an optimization
- Preserves backward compatibility while allowing efficient overrides
- All tests pass with the new implementation

Fixes #53

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] Count method is not basic. It is optimization. Make Count method an optimization by providing default implementation using Each Sep 13, 2025
@konard konard marked this pull request as ready for review September 13, 2025 15:53
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.

Count method is not basic. It is optimization.

2 participants