Skip to content

Commit 39e5e78

Browse files
oisdktreeowl
authored andcommitted
added since annotations to sorting functions (#518)
1 parent 3ff1715 commit 39e5e78

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Data/Sequence/Internal/Sorting.hs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,16 @@ import Utils.Containers.Internal.State (State(..), execState)
7878
-- | \( O(n \log n) \). 'sort' sorts the specified 'Seq' by the natural
7979
-- ordering of its elements. The sort is stable. If stability is not
8080
-- required, 'unstableSort' can be slightly faster.
81+
--
82+
-- @since 0.3.0
8183
sort :: Ord a => Seq a -> Seq a
8284
sort = sortBy compare
8385

8486
-- | \( O(n \log n) \). 'sortBy' sorts the specified 'Seq' according to the
8587
-- specified comparator. The sort is stable. If stability is not required,
8688
-- 'unstableSortBy' can be slightly faster.
89+
--
90+
-- @since 0.3.0
8791
sortBy :: (a -> a -> Ordering) -> Seq a -> Seq a
8892
sortBy cmp (Seq xs) =
8993
maybe
@@ -110,6 +114,8 @@ sortBy cmp (Seq xs) =
110114
-- If @f@ is very cheap (for example a record selector, or 'fst'),
111115
-- @'sortBy' ('compare' ``Data.Function.on`` f)@ will be faster than
112116
-- @'sortOn' f@.
117+
--
118+
-- @since 0.5.11
113119
sortOn :: Ord b => (a -> b) -> Seq a -> Seq a
114120
sortOn f (Seq xs) =
115121
maybe
@@ -123,13 +129,17 @@ sortOn f (Seq xs) =
123129

124130
-- Notes on the implementation and choice of heap are available in
125131
-- the file sorting.md (in this directory).
132+
--
133+
-- @since 0.3.0
126134
unstableSort :: Ord a => Seq a -> Seq a
127135
unstableSort = unstableSortBy compare
128136

129137
-- | \( O(n \log n) \). A generalization of 'unstableSort', 'unstableSortBy'
130138
-- takes an arbitrary comparator and sorts the specified sequence.
131139
-- The sort is not stable. This algorithm is frequently faster and
132140
-- uses less memory than 'sortBy'.
141+
--
142+
-- @since 0.3.0
133143
unstableSortBy :: (a -> a -> Ordering) -> Seq a -> Seq a
134144
unstableSortBy cmp (Seq xs) =
135145
maybe
@@ -156,6 +166,8 @@ unstableSortBy cmp (Seq xs) =
156166
-- If @f@ is very cheap (for example a record selector, or 'fst'),
157167
-- @'unstableSortBy' ('compare' ``Data.Function.on`` f)@ will be faster than
158168
-- @'unstableSortOn' f@.
169+
--
170+
-- @since 0.5.11
159171
unstableSortOn :: Ord b => (a -> b) -> Seq a -> Seq a
160172
unstableSortOn f (Seq xs) =
161173
maybe

0 commit comments

Comments
 (0)