add functions to Head
This commit is contained in:
15
src/v0.rs
15
src/v0.rs
@@ -782,6 +782,18 @@ impl Head{
|
|||||||
pub const fn new()->Self{
|
pub const fn new()->Self{
|
||||||
Self([0;NUM_EVENT_TYPES])
|
Self([0;NUM_EVENT_TYPES])
|
||||||
}
|
}
|
||||||
|
pub fn after_time(block:&Block,time:f64)->Self{
|
||||||
|
Self([
|
||||||
|
block.input_events.partition_point(|event|time<=event.time),
|
||||||
|
block.output_events.partition_point(|event|time<=event.time),
|
||||||
|
block.sound_events.partition_point(|event|time<=event.time),
|
||||||
|
block.world_events.partition_point(|event|time<=event.time),
|
||||||
|
block.gravity_events.partition_point(|event|time<=event.time),
|
||||||
|
block.run_events.partition_point(|event|time<=event.time),
|
||||||
|
block.camera_events.partition_point(|event|time<=event.time),
|
||||||
|
block.setting_events.partition_point(|event|time<=event.time),
|
||||||
|
])
|
||||||
|
}
|
||||||
// compare an event at the head of the plan to the best event collected so far.
|
// compare an event at the head of the plan to the best event collected so far.
|
||||||
fn collect_event<E>(
|
fn collect_event<E>(
|
||||||
&self,
|
&self,
|
||||||
@@ -822,6 +834,9 @@ impl Head{
|
|||||||
pub const fn get_event_index(&self,event_type:EventType)->usize{
|
pub const fn get_event_index(&self,event_type:EventType)->usize{
|
||||||
self.0[event_type as usize]
|
self.0[event_type as usize]
|
||||||
}
|
}
|
||||||
|
pub const fn set_event_index(&mut self,event_type:EventType,index:usize){
|
||||||
|
self.0[event_type as usize]=index;
|
||||||
|
}
|
||||||
/// Add the new event.
|
/// Add the new event.
|
||||||
pub const fn push(&mut self,event_type:EventType){
|
pub const fn push(&mut self,event_type:EventType){
|
||||||
self.0[event_type as usize]+=1;
|
self.0[event_type as usize]+=1;
|
||||||
|
|||||||
Reference in New Issue
Block a user