Trait necsim_core::cogs::habitat::Habitat

source ·
pub trait Habitat<M: MathsCore>: Backup + Debug + Sized {
    type LocationIterator<'a>: Iterator<Item = Location> + 'a
       where Self: 'a;

    // Provided methods
    fn is_finite(&self) -> bool { ... }
    fn get_extent(&self) -> &LandscapeExtent { ... }
    fn is_location_habitable(&self, location: &Location) -> bool { ... }
    fn is_indexed_location_habitable(
        &self,
        indexed_location: &IndexedLocation
    ) -> bool { ... }
    fn get_total_habitat(&self) -> OffByOneU64 { ... }
    fn get_habitat_at_location(&self, location: &Location) -> u32 { ... }
    fn map_indexed_location_to_u64_injective(
        &self,
        indexed_location: &IndexedLocation
    ) -> u64 { ... }
    fn iter_habitable_locations(&self) -> Self::LocationIterator<'_> { ... }
}

Required Associated Types§

source

type LocationIterator<'a>: Iterator<Item = Location> + 'a where Self: 'a

Provided Methods§

source

fn is_finite(&self) -> bool

source

fn get_extent(&self) -> &LandscapeExtent

source

fn is_location_habitable(&self, location: &Location) -> bool

source

fn is_indexed_location_habitable( &self, indexed_location: &IndexedLocation ) -> bool

source

fn get_total_habitat(&self) -> OffByOneU64

§Contracts

Post-condition - debug: total habitat is the sum of all habitat in the extent of the habitat

  • ! self.is_finite() || ret.get() == { self.iter_habitable_locations().map(|location| u128::from(self.get_habitat_at_location(&location))).sum() }
source

fn get_habitat_at_location(&self, location: &Location) -> u32

§Contracts

Pre-condition - debug: location is inside habitat extent

  • self.get_extent().contains(location)
source

fn map_indexed_location_to_u64_injective( &self, indexed_location: &IndexedLocation ) -> u64

§Contracts

Pre-condition - debug: location is inside habitat extent

  • self.get_extent().contains(indexed_location.location())

Pre-condition - debug: index is within the location’s habitat capacity

  • indexed_location.index() < self.get_habitat_at_location(indexed_location.location())
source

fn iter_habitable_locations(&self) -> Self::LocationIterator<'_>

Object Safety§

This trait is not object safe.

Implementors§