Skip to content

Conversation

antiguru
Copy link
Member

Add a Rhs parameter to PartialOrder, to allow comparison between different types. This helps to compare types stored in containers in a different form than their original structure.

Change the `PartialOrder` trait to have an optional right-hand side type.
This allows us to implement partial order for unequal types, which comes
in handy when working with complex timestamp times that a container might
store as a GAT instead of the actual type.

Signed-off-by: Moritz Hoffmann <[email protected]>
@antiguru antiguru force-pushed the partial_order_rhs branch from 179d6f7 to b73e476 Compare May 22, 2024 19:58
Copy link
Member

@frankmcsherry frankmcsherry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, with a few light comments.

/// assert!(frontier.insert_or_else(&2, |x| *x));
/// assert!(!frontier.insert(3));
///```
pub fn insert_or_else<O: PartialOrder<T>, F: FnOnce(&O) -> T>(&mut self, element: &O, to_owned: F) -> bool where T: Clone + PartialOrder<O> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, but I think _or_else isn't right, in that on insertion it does use the to_owned function. What about insert_with or something similar?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to insert_with.

Comment on lines 481 to 482
O: PartialOrder<T>,
T: PartialOrder<O>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of these two is surprising, but I don't know which. Probably O: PartialOrder<T>. With a time: &O, surely we can compare the elements of self.frontier() to time just using T: PartialOrder<O>?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, brain :fart: :)

where
T: PartialOrder,
O: PartialOrder<T>,
T: PartialOrder<O>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar as above; is one constraint unnecessary?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep!

Signed-off-by: Moritz Hoffmann <[email protected]>
@antiguru antiguru force-pushed the partial_order_rhs branch from 1df2749 to 4962a76 Compare May 22, 2024 20:42
@antiguru antiguru merged commit 5112400 into TimelyDataflow:master May 23, 2024
@antiguru antiguru deleted the partial_order_rhs branch May 23, 2024 14:10
@github-actions github-actions bot mentioned this pull request Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants