lexicographical_order 1.0.0
lexicographical_order: ^1.0.0 copied to clipboard
A string generator that helps to implement a lexicographical order.
Lexicographical Order #
A string generator that helps to implement a lexicographical order.
Installing #
dependencies:
lexicographical_order:
import 'package:lexicographical_order/lexicographical_order.dart';
Usage #
-
Get the string between two strings in a lexicographical order.
final mid = between(prev: 'B', next: 'D'); final list = [mid, 'D', 'B']; assert(listEqauls(list..sort(), ['B', mid, 'D']);
-
practice
class Todo { final int id; String title; bool completed String _orderKey; void reorderBetween(Todo? prev, Todo? next) { _orderKey = between( prev: prev?._orderKey, next: next?._orderKey, ); } Todo(/* omitted */); }
-
-
Generates strings that satisfy the minimum average string length and lexicographic order.
const stringCount = 100; List<String> orderKeys = generateOrderKeys(stringCount).toList();
Caution #
-
Don't use 'A' as first order key
In the lexicographical order, no character can precede 'A'.