MCPcopy Create free account
hub / github.com/It4innovations/hyperqueue / push

Method push

crates/hyperqueue/src/dashboard/data/time_based_vec.rs:17–30  ·  view source on GitHub ↗
(&mut self, time: Time, item: T)

Source from the content-addressed store, hash-verified

15
16impl<T> TimeBasedVec<T> {
17 pub fn push(&mut self, time: Time, item: T) {
18 // Fast path: we're appending an event that should be at the end of the vec
19 if self
20 .items
21 .last()
22 .map(|item| item.time < time)
23 .unwrap_or(true)
24 {
25 self.items.push(ItemWithTime { time, item });
26 } else {
27 let index = self.items.partition_point(|item| item.time < time);
28 self.items.insert(index, ItemWithTime { time, item });
29 }
30 }
31
32 /// Returns the most recent item that has happened before or at `time`.
33 pub fn get_most_recent_at(&self, time: Time) -> Option<&ItemWithTime<T>> {

Callers 15

args_to_paramsFunction · 0.80
gather_configurationFunction · 0.80
warn_array_task_countFunction · 0.80
extract_metadataFunction · 0.80
add_changeMethod · 0.80
add_valueMethod · 0.80
task_start_stopMethod · 0.80
new_workerMethod · 0.80

Calls 1

insertMethod · 0.45