Skip to content

Add Diff<T> class for computing set differences#1779

Merged
yegor256 merged 2 commits intoyegor256:masterfrom
alimansour0002:master
Mar 17, 2025
Merged

Add Diff<T> class for computing set differences#1779
yegor256 merged 2 commits intoyegor256:masterfrom
alimansour0002:master

Conversation

@alimansour0002
Copy link
Copy Markdown
Contributor

PR Description

## Description
This PR introduces a new `Diff<T>` class that computes the set difference operation (A - B) between two sets. The class extends `SetEnvelope<T>` and provides multiple constructors to support different input types:

- Iterable<T>
- Iterator<T>
- Scalar<Iterable<T>>
- SetOf<T>

The implementation follows the Cactoos object-oriented approach and includes comprehensive test coverage.

## Implementation Details
- The `Diff` class computes elements that are in the first set but not in the second set
- Added multiple constructors to support various input types
- Implemented a private `computeDiff` method to handle the actual set difference operation
- Added thorough test cases covering various scenarios:
  - Basic set difference
  - Empty set handling (both first and second sets)
  - Working with java.util.Set
  - Working with Iterables and Iterators

## Test Coverage
The implementation includes tests for all edge cases and typical usage scenarios:
- Computing difference between two non-empty sets
- Computing difference with an empty second set
- Computing difference with an empty first set
- Working with java.util.Set instances
- Working with Iterables and Iterators

All tests pass successfully, demonstrating the correctness of the implementation.

alimansour0002 and others added 2 commits March 16, 2025 21:58
Implemented a new Diff class that computes the difference between two sets.
The class extends SetEnvelope and provides multiple constructors to support
different input types (Iterable, Iterator, Scalar). Added comprehensive tests
to verify functionality.
@yegor256 yegor256 merged commit 85f5d30 into yegor256:master Mar 17, 2025
14 checks passed
@yegor256
Copy link
Copy Markdown
Owner

@alimansour0002 perfect, thanks!

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.

2 participants