-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Implement the SortBy
stream adapter
#43
Merged
Merged
Commits on Jan 11, 2024
-
feat: Replace
arrayvec
bysmallvec
.The motivation behind this patch is to replace `arrayvec` by `smallvec`. Why? Because `arrayvec` cannot grow, it's an array-baked vector. Once the full capacity is reached, it cannot grow any more. That was fine up until now because it was only used by the `Limit` stream adapter which needs only 2 values in a buffer that is typed by an `ArrayVec`. But for other stream adapters, it's a limitation. What if a stream adapter needs a buffer of more than 2 values? Ideally, we want to preserve the stack-allocated property for obvious performance reasons (cache locality, reducing allocator traffic and so on). However, we also want to be able to fallback to the heap for larger allocations. `smallvec` provides this feature. Hence, it does what `arrayvec` does, with the addition of heap-allocated fallback when it's needed.
Configuration menu - View commit details
-
Copy full SHA for 9ecfc62 - Browse repository at this point
Copy the full SHA 9ecfc62View commit details -
chore: Rename
VectorDiffContainerStreamLimitBuf
.This type alias is renamed to `VectorDiffContainerStreamBuffer`.
Configuration menu - View commit details
-
Copy full SHA for d0173f6 - Browse repository at this point
Copy the full SHA d0173f6View commit details
Commits on Jan 21, 2024
-
feat: Implement the
Sort
stream adapter.`Sort` is `VectorDiff` stream adapter that presents a sorted view of the underlying `ObservableVector` items. ```rust use eyeball_im::{ObservableVector, VectorDiff}; use eyeball_im_util::vector::VectorObserverExt; use imbl::vector; use std::cmp::Ordering; use stream_assert::{assert_closed, assert_next_eq, assert_pending}; // A comparison function that is used to sort our // `ObservableVector` values. fn cmp<T>(left: &T, right: &T) -> Ordering where T: Ord, { left.cmp(right) } // Our vector. let mut ob = ObservableVector::<char>::new(); let (values, mut sub) = ob.subscribe().sort(cmp); // ^^^ // | our comparison function assert!(values.is_empty()); assert_pending!(sub); // Append multiple unsorted values. ob.append(vector!['d', 'b', 'e']); // We get a `VectorDiff::Append` with sorted values! assert_next_eq!(sub, VectorDiff::Append { values: vector!['b', 'd', 'e'] }); // Let's recap what we have. `ob` is our `ObservableVector`, // `sub` is the “sorted view”/“sorted stream” of `ob`: // | `ob` | d b e | // | `sub` | b d e | // Append other multiple values. ob.append(vector!['f', 'g', 'a', 'c']); // We get three `VectorDiff`s! assert_next_eq!(sub, VectorDiff::PushFront { value: 'a' }); assert_next_eq!(sub, VectorDiff::Insert { index: 2, value: 'c' }); assert_next_eq!(sub, VectorDiff::Append { values: vector!['f', 'g'] }); // Let's recap what we have: // | `ob` | d b e f g a c | // | `sub` | a b c d e f g | // ^ ^ ^^^ // | | | // | | with `VectorDiff::Append { .. }` // | with `VectorDiff::Insert { index: 2, .. }` // with `VectorDiff::PushFront { .. }` // Technically, `Sort` emits `VectorDiff` that mimics a sorted `Vector`. drop(ob); assert_closed!(sub); ```
Configuration menu - View commit details
-
Copy full SHA for 4970ec0 - Browse repository at this point
Copy the full SHA 4970ec0View commit details
Commits on Jan 22, 2024
-
Configuration menu - View commit details
-
Copy full SHA for c51b10d - Browse repository at this point
Copy the full SHA c51b10dView commit details -
Configuration menu - View commit details
-
Copy full SHA for e8a51b6 - Browse repository at this point
Copy the full SHA e8a51b6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 15e77e5 - Browse repository at this point
Copy the full SHA 15e77e5View commit details -
Configuration menu - View commit details
-
Copy full SHA for c729d94 - Browse repository at this point
Copy the full SHA c729d94View commit details -
Configuration menu - View commit details
-
Copy full SHA for d2692ae - Browse repository at this point
Copy the full SHA d2692aeView commit details
Commits on Jan 31, 2024
-
feat: Use binary search for better performance.
This patch uses a binary search when the position of a value must be found. Finding a new value based on the `compare` function can be costly, hence the use of a binary search.
Configuration menu - View commit details
-
Copy full SHA for c08bac6 - Browse repository at this point
Copy the full SHA c08bac6View commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.