operator == method
- Object other
override
We are implementing equals ourselves instead of using equatable, because we want to compare the sets of triples, not the order
Compares this graph to another object for equality. Two RDF graphs are equal if they contain the same set of triples, regardless of the order in which they were added.
This implementation treats RDF graphs as sets rather than lists, which aligns with the semantic definition of RDF graphs in the specification.
Implementation
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
if (other is! RdfGraph) return false;
// Compare triple sets (order doesn't matter in RDF graphs)
final Set<Triple> thisTriples = _triples.toSet();
final Set<Triple> otherTriples = other._triples.toSet();
return thisTriples.length == otherTriples.length &&
thisTriples.containsAll(otherTriples);
}