Struct rust_sc2::units::Units [−][src]
pub struct Units(_);
Convinient Unit
s collection.
Implementations
impl Units
[src]
impl Units
[src]pub fn new() -> Self
[src]
Constrructs new empty units collection.
pub fn with_capacity(n: usize) -> Self
[src]
Constructs new units collection with given capacity.
pub fn capacity(&self) -> usize
[src]
Returns current capacity of the collection.
pub fn reserve(&mut self, additional: usize)
[src]
Reserves additional capacity in the collection.
pub fn shrink_to_fit(&mut self)
[src]
Shrinks the capacity as much as possible.
pub fn first(&self) -> Option<&Unit>
[src]
Returns first unit in the collection.
pub fn push(&mut self, u: Unit) -> Option<Unit>
[src]
Inserts unit in the collection.
If collection already contains unit with the same tag, replaces it and returns previous unit.
pub fn pop(&mut self) -> Option<Unit>
[src]
Removes and returns last unit from the collection.
Returns None
if the collection is empty.
pub fn remove(&mut self, u: u64) -> Option<Unit>
[src]
Removes and returns unit with given tag.
Returns None
if there’s no unit with such tag in the collection.
pub fn iter(&self) -> Values<'_, u64, Unit>
[src]
Returns an iterator over the units of the collection.
pub fn iter_mut(&mut self) -> ValuesMut<'_, u64, Unit>
[src]
Returns mutable iterator over the units of the collection.
pub fn pairs(&self) -> Iter<'_, u64, Unit>
[src]
Returns an iterator over (tag, unit) pairs of the collection.
pub fn pairs_mut(&mut self) -> IterMut<'_, u64, Unit>
[src]
Returns mutable iterator over (tag, unit) pairs of the collection.
pub fn tags(&self) -> Keys<'_, u64, Unit>
[src]
Returns an iterator over unit tags of the collection.
pub fn is_empty(&self) -> bool
[src]
Returns true
if collection contains no units.
pub fn len(&self) -> usize
[src]
Returns the current number of units in the collection.
pub fn clear(&mut self)
[src]
Removes all units from the collection, while preserving its capacity.
pub fn contains_tag(&self, tag: u64) -> bool
[src]
Checks if the collection contains unit with given tag.
pub fn get(&self, tag: u64) -> Option<&Unit>
[src]
Returns a reference to unit with given tag or None
if there’s no unit with such tag.
pub fn get_mut(&mut self, tag: u64) -> Option<&mut Unit>
[src]
Returns a mutable reference to unit with given tag or None
if there’s no unit with such tag.
pub fn find_tags<'a, T: IntoIterator<Item = &'a u64>>(&self, tags: T) -> Self
[src]
Searches for units with given tags and makes new collection of them.
Warning: This method will clone units in order to create a new collection
and will be evaluated initially. When applicable prefer using find_tags
on the iterator over units, since it’s lazily evaluated and doesn’t do any cloning operations.
pub fn of_type(&self, unit_type: UnitTypeId) -> Self
[src]
Leaves only units of given type and makes a new collection of them.
Warning: This method will clone units in order to create a new collection
and will be evaluated initially. When applicable prefer using of_type
on the iterator over units, since it’s lazily evaluated and doesn’t do any cloning operations.
pub fn exclude_type(&self, unit_type: UnitTypeId) -> Self
[src]
Excludes all units of given type and makes a new collection of remaining units.
Warning: This method will clone units in order to create a new collection
and will be evaluated initially. When applicable prefer using exclude_type
on the iterator over units, since it’s lazily evaluated and doesn’t do any cloning operations.
pub fn center(&self) -> Option<Point2>
[src]
Returns central position of all units in the collection or None
if collection is empty.
pub fn ground(&self) -> Self
[src]
Leaves only non-flying units and makes new collection of them.
Warning: This method will clone units in order to create a new collection
and will be evaluated initially. When applicable prefer using ground
on the iterator over units, since it’s lazily evaluated and doesn’t do any cloning operations.
pub fn flying(&self) -> Self
[src]
Leaves only flying units and makes new collection of them.
Warning: This method will clone units in order to create a new collection
and will be evaluated initially. When applicable prefer using flying
on the iterator over units, since it’s lazily evaluated and doesn’t do any cloning operations.
pub fn ready(&self) -> Self
[src]
Leaves only ready structures and makes new collection of them.
Warning: This method will clone units in order to create a new collection
and will be evaluated initially. When applicable prefer using ready
on the iterator over units, since it’s lazily evaluated and doesn’t do any cloning operations.
pub fn not_ready(&self) -> Self
[src]
Leaves only structures in-progress and makes new collection of them.
Warning: This method will clone units in order to create a new collection
and will be evaluated initially. When applicable prefer using not_ready
on the iterator over units, since it’s lazily evaluated and doesn’t do any cloning operations.
pub fn idle(&self) -> Self
[src]
Leaves only units with no orders and makes new collection of them.
Warning: This method will clone units in order to create a new collection
and will be evaluated initially. When applicable prefer using idle
on the iterator over units, since it’s lazily evaluated and doesn’t do any cloning operations.
pub fn almost_idle(&self) -> Self
[src]
Leaves only units with no orders or that almost finished their orders and makes new collection of them.
Warning: This method will clone units in order to create a new collection
and will be evaluated initially. When applicable prefer using almost_idle
on the iterator over units, since it’s lazily evaluated and doesn’t do any cloning operations.
pub fn unused(&self) -> Self
[src]
Leaves only units with no orders and makes new collection of them.
Unlike idle
this takes reactor on terran buildings into account.
Warning: This method will clone units in order to create a new collection
and will be evaluated initially. When applicable prefer using unused
on the iterator over units, since it’s lazily evaluated and doesn’t do any cloning operations.
pub fn almost_unused(&self) -> Self
[src]
Leaves only units with no orders or that almost finished their orders and makes new collection of them.
Unlike almost_idle
this takes reactor on terran buildings into account.
Warning: This method will clone units in order to create a new collection
and will be evaluated initially. When applicable prefer using almost_unused
on the iterator over units, since it’s lazily evaluated and doesn’t do any cloning operations.
pub fn in_range_of(&self, unit: &Unit, gap: f32) -> Self
[src]
Leaves only units in attack range of given unit and makes new collection of them.
Warning: This method will clone units in order to create a new collection
and will be evaluated initially. When applicable prefer using in_range_of
on the iterator over units, since it’s lazily evaluated and doesn’t do any cloning operations.
pub fn in_range(&self, unit: &Unit, gap: f32) -> Self
[src]
Leaves only units that are close enough to attack given unit and makes new collection of them.
Warning: This method will clone units in order to create a new collection
and will be evaluated initially. When applicable prefer using in_range
on the iterator over units, since it’s lazily evaluated and doesn’t do any cloning operations.
pub fn in_real_range_of(&self, unit: &Unit, gap: f32) -> Self
[src]
Leaves only units in attack range of given unit and makes new collection of them.
Unlike in_range_of
this takes range upgrades into account.
Warning: This method will clone units in order to create a new collection
and will be evaluated initially. When applicable prefer using in_real_range_of
on the iterator over units, since it’s lazily evaluated and doesn’t do any cloning operations.
pub fn in_real_range(&self, unit: &Unit, gap: f32) -> Self
[src]
Leaves only units that are close enough to attack given unit and makes new collection of them.
Unlike in_range
this takes range upgrades into account.
Warning: This method will clone units in order to create a new collection
and will be evaluated initially. When applicable prefer using in_real_range
on the iterator over units, since it’s lazily evaluated and doesn’t do any cloning operations.
pub fn visible(&self) -> Self
[src]
Leaves only units visible on current step and makes new collection of them.
Warning: This method will clone units in order to create a new collection
and will be evaluated initially. When applicable prefer using visible
on the iterator over units, since it’s lazily evaluated and doesn’t do any cloning operations.
pub fn sort<T, F>(&mut self, f: F) where
T: PartialOrd,
F: Fn(&Unit) -> T,
[src]
T: PartialOrd,
F: Fn(&Unit) -> T,
Sorts the collection by given function.
pub fn sorted<T, F>(&self, f: F) -> Self where
T: PartialOrd,
F: Fn(&Unit) -> T,
[src]
T: PartialOrd,
F: Fn(&Unit) -> T,
Makes new collection sorted by given function. Leaves original collection untouched.
impl Units
[src]
impl Units
[src]pub fn filter<F>(&self, f: F) -> Self where
F: Fn(&&Unit) -> bool,
[src]
F: Fn(&&Unit) -> bool,
Leaves only units that match given predicate and makes new collection of them.
Warning: This method will clone units in order to create a new collection
and will be evaluated initially. When applicable prefer using filter
on the iterator over units, since it’s lazily evaluated and doesn’t do any cloning operations.
pub fn of_types<T: Container<UnitTypeId>>(&self, types: &T) -> Self
[src]
Leaves only units of given types and makes a new collection of them.
Warning: This method will clone units in order to create a new collection
and will be evaluated initially. When applicable prefer using of_types
on the iterator over units, since it’s lazily evaluated and doesn’t do any cloning operations.
pub fn exclude_types<T: Container<UnitTypeId>>(&self, types: &T) -> Self
[src]
Excludes units of given types and makes a new collection of remaining units.
Warning: This method will clone units in order to create a new collection
and will be evaluated initially. When applicable prefer using exclude_types
on the iterator over units, since it’s lazily evaluated and doesn’t do any cloning operations.
pub fn closer<P: Into<Point2> + Copy>(&self, distance: f32, target: P) -> Self
[src]
Leaves only units closer than given distance to target and makes new collection of them.
Warning: This method will clone units in order to create a new collection
and will be evaluated initially. When applicable prefer using closer
on the iterator over units, since it’s lazily evaluated and doesn’t do any cloning operations.
pub fn further<P: Into<Point2> + Copy>(&self, distance: f32, target: P) -> Self
[src]
Leaves only units further than given distance to target and makes new collection of them.
Warning: This method will clone units in order to create a new collection
and will be evaluated initially. When applicable prefer using further
on the iterator over units, since it’s lazily evaluated and doesn’t do any cloning operations.
pub fn closest<P: Into<Point2> + Copy>(&self, target: P) -> Option<&Unit>
[src]
Returns closest from the collection unit to given target.
pub fn furthest<P: Into<Point2> + Copy>(&self, target: P) -> Option<&Unit>
[src]
Returns furthest from the collection unit to given target.
pub fn closest_distance<P: Into<Point2> + Copy>(&self, target: P) -> Option<f32>
[src]
Returns distance from closest unit in the collection to given target.
pub fn furthest_distance<P: Into<Point2> + Copy>(
&self,
target: P
) -> Option<f32>
[src]
&self,
target: P
) -> Option<f32>
Returns distance from furthest unit in the collection to given target.
pub fn closest_distance_squared<P: Into<Point2> + Copy>(
&self,
target: P
) -> Option<f32>
[src]
&self,
target: P
) -> Option<f32>
Returns squared distance from closest unit in the collection to given target.
pub fn furthest_distance_squared<P: Into<Point2> + Copy>(
&self,
target: P
) -> Option<f32>
[src]
&self,
target: P
) -> Option<f32>
Returns squared distance from furthest unit in the collection to given target.
pub fn sum<T, F>(&self, f: F) -> T where
T: Sum,
F: Fn(&Unit) -> T,
[src]
T: Sum,
F: Fn(&Unit) -> T,
Returns sum of given unit values.
pub fn min<T, F>(&self, f: F) -> Option<&Unit> where
T: PartialOrd,
F: Fn(&Unit) -> T,
[src]
T: PartialOrd,
F: Fn(&Unit) -> T,
Returns unit with minimum given predicate.
pub fn min_value<T, F>(&self, f: F) -> Option<T> where
T: PartialOrd,
F: Fn(&Unit) -> T,
[src]
T: PartialOrd,
F: Fn(&Unit) -> T,
Returns minimum of given unit values.
pub fn max<T, F>(&self, f: F) -> Option<&Unit> where
T: PartialOrd,
F: Fn(&Unit) -> T,
[src]
T: PartialOrd,
F: Fn(&Unit) -> T,
Returns unit with maximum given predicate.
pub fn max_value<T, F>(&self, f: F) -> Option<T> where
T: PartialOrd,
F: Fn(&Unit) -> T,
[src]
T: PartialOrd,
F: Fn(&Unit) -> T,
Returns maximum of given unit values.
Trait Implementations
impl Extend<(u64, Unit)> for Units
[src]
impl Extend<(u64, Unit)> for Units
[src]fn extend<T: IntoIterator<Item = (u64, Unit)>>(&mut self, iter: T)
[src]
pub fn extend_one(&mut self, item: A)
[src]
pub fn extend_reserve(&mut self, additional: usize)
[src]
impl Extend<Unit> for Units
[src]
impl Extend<Unit> for Units
[src]fn extend<T: IntoIterator<Item = Unit>>(&mut self, iter: T)
[src]
pub fn extend_one(&mut self, item: A)
[src]
pub fn extend_reserve(&mut self, additional: usize)
[src]
impl FromIterator<Unit> for Units
[src]
impl FromIterator<Unit> for Units
[src]fn from_iter<I: IntoIterator<Item = Unit>>(iter: I) -> Self
[src]
impl IntoIterator for Units
[src]
impl IntoIterator for Units
[src]impl<'a> IntoIterator for &'a Units
[src]
impl<'a> IntoIterator for &'a Units
[src]Auto Trait Implementations
impl !RefUnwindSafe for Units
impl !RefUnwindSafe for Units
impl !UnwindSafe for Units
impl !UnwindSafe for Units