Struct rust_sc2::units::Units [−][src]
pub struct Units(_);
Expand description
Convinient Unit
s collection.
Implementations
impl Units
[src]
impl Units
[src]pub fn with_capacity(n: usize) -> Self
[src]
pub fn with_capacity(n: usize) -> Self
[src]Constructs new units collection with given capacity.
pub fn shrink_to_fit(&mut self)
[src]
pub fn shrink_to_fit(&mut self)
[src]Shrinks the capacity as much as possible.
pub fn push(&mut self, u: Unit) -> Option<Unit>
[src]
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]
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]
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]
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]
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]
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]
pub fn pairs_mut(&mut self) -> IterMut<'_, u64, Unit>
[src]Returns mutable iterator over (tag, unit) pairs of the collection.
pub fn contains_tag(&self, tag: u64) -> bool
[src]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
pub fn sort<T, F>(&mut self, f: F) where
T: PartialOrd,
F: Fn(&Unit) -> T,
[src]Sorts the collection by given function.
pub fn sorted<T, F>(&self, f: F) -> Self where
T: PartialOrd,
F: Fn(&Unit) -> T,
[src]
pub fn sorted<T, F>(&self, f: F) -> Self where
T: PartialOrd,
F: Fn(&Unit) -> T,
[src]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]
pub fn filter<F>(&self, f: F) -> Self where
F: Fn(&&Unit) -> bool,
[src]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]
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]
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]
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]
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]
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]
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]
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]
pub fn furthest_distance<P: Into<Point2> + Copy>(
&self,
target: P
) -> Option<f32>
[src]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]
pub fn closest_distance_squared<P: Into<Point2> + Copy>(
&self,
target: P
) -> Option<f32>
[src]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]
pub fn furthest_distance_squared<P: Into<Point2> + Copy>(
&self,
target: P
) -> Option<f32>
[src]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]
pub fn sum<T, F>(&self, f: F) -> T where
T: Sum,
F: Fn(&Unit) -> T,
[src]Returns sum of given unit values.
pub fn min<T, F>(&self, f: F) -> Option<&Unit> where
T: PartialOrd,
F: Fn(&Unit) -> T,
[src]
pub fn min<T, F>(&self, f: F) -> Option<&Unit> where
T: PartialOrd,
F: Fn(&Unit) -> T,
[src]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]
pub fn min_value<T, F>(&self, f: F) -> Option<T> where
T: PartialOrd,
F: Fn(&Unit) -> T,
[src]Returns minimum 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]
fn extend<T: IntoIterator<Item = (u64, Unit)>>(&mut self, iter: T)
[src]Extends a collection with the contents of an iterator. Read more
fn extend_one(&mut self, item: A)
[src]
fn extend_one(&mut self, item: A)
[src]extend_one
)Extends a collection with exactly one element.
fn extend_reserve(&mut self, additional: usize)
[src]
fn extend_reserve(&mut self, additional: usize)
[src]extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
impl Extend<Unit> for Units
[src]
impl Extend<Unit> for Units
[src]fn extend<T: IntoIterator<Item = Unit>>(&mut self, iter: T)
[src]
fn extend<T: IntoIterator<Item = Unit>>(&mut self, iter: T)
[src]Extends a collection with the contents of an iterator. Read more
fn extend_one(&mut self, item: A)
[src]
fn extend_one(&mut self, item: A)
[src]extend_one
)Extends a collection with exactly one element.
fn extend_reserve(&mut self, additional: usize)
[src]
fn extend_reserve(&mut self, additional: usize)
[src]extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
impl FromIterator<Unit> for Units
[src]
impl FromIterator<Unit> for Units
[src]fn from_iter<I: IntoIterator<Item = Unit>>(iter: I) -> Self
[src]
fn from_iter<I: IntoIterator<Item = Unit>>(iter: I) -> Self
[src]Creates a value from an iterator. Read more
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 !Send for Units
impl !Sync for Units
impl Unpin for Units
impl !UnwindSafe for Units
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,