Skip to content

API proposal: SequenceEqual implementations for ReadOnlySequence<T> #518

@zlatanov

Description

@zlatanov

I think it's rather unfortunate that ReadOnlySequences cannot be easily checked for value equality. The framework has such extension methods for Spans and ReadOnlySpans - SequenceEqual and the type that has Sequence in its name doesn't.

Implementing it efficiently is tricky because one needs to consider that segments may not be of the same size and even there can be empty segments that need to be ignored.

Proposed API

class MemoryExtensions
{
    static bool SequenceEqual<T>(this in ReadOnlySequence<T> x, in ReadOnlySequence<T> y);
    static bool SequenceEqual<T>(this in ReadOnlySequence<T> x, in ReadOnlySpan<T> y);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-System.Memory

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions