feat: add insert_after and insert_startup_before (#13941)
# Objective Fixes #13866 ## Solution Add `insert_before` in **FixedMainScheduleOrder** and **MainScheduleOrder**, add `insert_startup_before` in **MainScheduleOrder**, applying the same logic as `insert_after`, except for parameters naming and insertion index.
This commit is contained in:
parent
6eec73a9a5
commit
2f9c42bb33
@ -195,6 +195,16 @@ impl MainScheduleOrder {
|
|||||||
self.labels.insert(index + 1, schedule.intern());
|
self.labels.insert(index + 1, schedule.intern());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Adds the given `schedule` before the `before` schedule in the main list of schedules.
|
||||||
|
pub fn insert_before(&mut self, before: impl ScheduleLabel, schedule: impl ScheduleLabel) {
|
||||||
|
let index = self
|
||||||
|
.labels
|
||||||
|
.iter()
|
||||||
|
.position(|current| (**current).eq(&before))
|
||||||
|
.unwrap_or_else(|| panic!("Expected {before:?} to exist"));
|
||||||
|
self.labels.insert(index, schedule.intern());
|
||||||
|
}
|
||||||
|
|
||||||
/// Adds the given `schedule` after the `after` schedule in the list of startup schedules.
|
/// Adds the given `schedule` after the `after` schedule in the list of startup schedules.
|
||||||
pub fn insert_startup_after(
|
pub fn insert_startup_after(
|
||||||
&mut self,
|
&mut self,
|
||||||
@ -208,6 +218,20 @@ impl MainScheduleOrder {
|
|||||||
.unwrap_or_else(|| panic!("Expected {after:?} to exist"));
|
.unwrap_or_else(|| panic!("Expected {after:?} to exist"));
|
||||||
self.startup_labels.insert(index + 1, schedule.intern());
|
self.startup_labels.insert(index + 1, schedule.intern());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Adds the given `schedule` before the `before` schedule in the list of startup schedules.
|
||||||
|
pub fn insert_startup_before(
|
||||||
|
&mut self,
|
||||||
|
before: impl ScheduleLabel,
|
||||||
|
schedule: impl ScheduleLabel,
|
||||||
|
) {
|
||||||
|
let index = self
|
||||||
|
.startup_labels
|
||||||
|
.iter()
|
||||||
|
.position(|current| (**current).eq(&before))
|
||||||
|
.unwrap_or_else(|| panic!("Expected {before:?} to exist"));
|
||||||
|
self.startup_labels.insert(index, schedule.intern());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Main {
|
impl Main {
|
||||||
@ -291,6 +315,16 @@ impl FixedMainScheduleOrder {
|
|||||||
.unwrap_or_else(|| panic!("Expected {after:?} to exist"));
|
.unwrap_or_else(|| panic!("Expected {after:?} to exist"));
|
||||||
self.labels.insert(index + 1, schedule.intern());
|
self.labels.insert(index + 1, schedule.intern());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Adds the given `schedule` before the `before` schedule
|
||||||
|
pub fn insert_before(&mut self, before: impl ScheduleLabel, schedule: impl ScheduleLabel) {
|
||||||
|
let index = self
|
||||||
|
.labels
|
||||||
|
.iter()
|
||||||
|
.position(|current| (**current).eq(&before))
|
||||||
|
.unwrap_or_else(|| panic!("Expected {before:?} to exist"));
|
||||||
|
self.labels.insert(index, schedule.intern());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FixedMain {
|
impl FixedMain {
|
||||||
|
Loading…
Reference in New Issue
Block a user