Skip to content

Commit

Permalink
Make SortedList a public API
Browse files Browse the repository at this point in the history
It is exposed so it should be public. (Constructor is private anyways)
  • Loading branch information
passsy committed Mar 4, 2022
1 parent c26758d commit 7acc45f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions lib/src/iterable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ extension IterableSortedBy<E> on Iterable<E> {
///
/// **Note:** The actual sorting is performed when an element is accessed for
/// the first time.
_SortedList<E> sortedBy(Comparable Function(E element) selector) {
return _SortedList<E>._withSelector(this, selector, 1, null);
SortedList<E> sortedBy(Comparable Function(E element) selector) {
return SortedList<E>._withSelector(this, selector, 1, null);
}
}

Expand All @@ -292,8 +292,8 @@ extension IterableSortedByDescending<E> on Iterable<E> {
///
/// **Note:** The actual sorting is performed when an element is accessed for
/// the first time.
_SortedList<E> sortedByDescending(Comparable Function(E element) selector) {
return _SortedList<E>._withSelector(this, selector, -1, null);
SortedList<E> sortedByDescending(Comparable Function(E element) selector) {
return SortedList<E>._withSelector(this, selector, -1, null);
}
}

Expand All @@ -306,8 +306,8 @@ extension IterableSortedWith<E> on Iterable<E> {
///
/// **Note:** The actual sorting is performed when an element is accessed for
/// the first time.
_SortedList<E> sortedWith(Comparator<E> comparator) {
return _SortedList<E>._(this, comparator);
SortedList<E> sortedWith(Comparator<E> comparator) {
return SortedList<E>._(this, comparator);
}
}

Expand Down
18 changes: 9 additions & 9 deletions lib/src/sorted_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ Comparator<E> _getComparator<E>(
return parent?.compose(newComparator) ?? newComparator;
}

class _SortedList<E> extends _DelegatingList<E> {
class SortedList<E> extends _DelegatingList<E> {
final Iterable<E> _source;
final Comparator<E> _comparator;
List<E>? _sortedResults;

_SortedList._(
SortedList._(
this._source,
this._comparator,
);

_SortedList._withSelector(
SortedList._withSelector(
this._source,
Comparable Function(E element) selector,
int order,
Expand All @@ -44,8 +44,8 @@ class _SortedList<E> extends _DelegatingList<E> {
///
/// **Note:** The actual sorting is performed when an element is accessed for
/// the first time.
_SortedList<E> thenBy(Comparable Function(E element) selector) {
return _SortedList<E>._withSelector(this, selector, 1, _comparator);
SortedList<E> thenBy(Comparable Function(E element) selector) {
return SortedList<E>._withSelector(this, selector, 1, _comparator);
}

/// Returns a new list with all elements sorted according to previously
Expand All @@ -54,17 +54,17 @@ class _SortedList<E> extends _DelegatingList<E> {
///
/// **Note:** The actual sorting is performed when an element is accessed for
/// the first time.
_SortedList<E> thenByDescending(Comparable Function(E element) selector) {
return _SortedList<E>._withSelector(this, selector, -1, _comparator);
SortedList<E> thenByDescending(Comparable Function(E element) selector) {
return SortedList<E>._withSelector(this, selector, -1, _comparator);
}

/// Returns a new list with all elements sorted according to previously
/// defined order and specified [comparator].
///
/// **Note:** The actual sorting is performed when an element is accessed for
/// the first time.
_SortedList<E> thenWith(Comparator<E> comparator) {
return _SortedList<E>._(this, _comparator.compose(comparator));
SortedList<E> thenWith(Comparator<E> comparator) {
return SortedList<E>._(this, _comparator.compose(comparator));
}

@override
Expand Down

0 comments on commit 7acc45f

Please sign in to comment.