summaryrefslogtreecommitdiff
path: root/morphology/README.md
diff options
context:
space:
mode:
authorjacksonfu14 <jackson@fashionunited.com>2025-11-11 08:12:01 +0100
committerJackson Moore <jacksonmoore@tuta.io>2025-11-11 08:12:01 +0100
commitd0e3dc212ea7d855bf5339a5f9904e681e7b363a (patch)
tree4ae71e1392120615759eaf7ec9511a98e194c7fc /morphology/README.md
parentcf758968d957de0fa2f1bf39a42d633b4fe74616 (diff)
feat: add sort with segregated sequence lengths
Diffstat (limited to 'morphology/README.md')
-rw-r--r--morphology/README.md9
1 files changed, 7 insertions, 2 deletions
diff --git a/morphology/README.md b/morphology/README.md
index dee8c3e..31c1e16 100644
--- a/morphology/README.md
+++ b/morphology/README.md
@@ -88,6 +88,9 @@ SortingMethod::BreadthFirst // Compare all outer values first, then all inner
SortingDirection::Forward // Compare sequences from first to last position
SortingDirection::Backward // Compare sequences from last to first position
+LengthSorting::InterpolateLength // Sequences of different lengths sorted together by content
+LengthSorting::SegregateLength // Sequences grouped by length, shorter sequences first
+
sort_sequences(&mut sequences, outer_order, inner_order)
```
@@ -168,7 +171,7 @@ let all_sets = generate_valid_sets(5);
```rust
use meta_affine::{ValidSet, Value, Sequence};
use meta_affine::sequence::{generate_sequences, generate_all_sequences, sort_sequences};
-use meta_affine::sequence::{SequenceOptions, PrecedenceOrder, SortingMethod, SortingDirection};
+use meta_affine::sequence::{SequenceOptions, PrecedenceOrder, SortingMethod, SortingDirection, LengthSorting};
// Create a valid set
let set = ValidSet::new()
@@ -177,11 +180,12 @@ let set = ValidSet::new()
// Generate all valid sequences of length 3 from this set
let mut sequences = generate_sequences(&set, 3);
-// Sort with defaults (Forward, DepthFirst, IncreasingPositiveFirst)
+// Sort with defaults (InterpolateLength, Forward, DepthFirst, IncreasingPositiveFirst)
sort_sequences(&mut sequences, None);
// Sort with custom options using builder pattern
let opts = SequenceOptions::new()
+ .length_sorting(LengthSorting::SegregateLength)
.sorting_direction(SortingDirection::Backward)
.sorting_method(SortingMethod::BreadthFirst)
.outer_order(PrecedenceOrder::IncreasingNegativeFirst)
@@ -190,6 +194,7 @@ sort_sequences(&mut sequences, opts);
// Generate all sequences from all valid sets with sorting options
let opts = SequenceOptions::new()
+ .length_sorting(LengthSorting::SegregateLength)
.sorting_method(SortingMethod::BreadthFirst)
.sorting_direction(SortingDirection::Backward);
let all_sequences = generate_all_sequences(3, opts);