Struct objc2_foundation::NSCountedSet
source · #[repr(C)]pub struct NSCountedSet<ObjectType: ?Sized = AnyObject> { /* private fields */ }
NSSet
only.Implementations§
source§impl<ObjectType: Message> NSCountedSet<ObjectType>
impl<ObjectType: Message> NSCountedSet<ObjectType>
pub unsafe fn initWithCapacity( this: Allocated<Self>, num_items: NSUInteger ) -> Retained<Self>
pub unsafe fn initWithArray( this: Allocated<Self>, array: &NSArray<ObjectType> ) -> Retained<Self>
NSArray
only.pub unsafe fn initWithSet( this: Allocated<Self>, set: &NSSet<ObjectType> ) -> Retained<Self>
pub unsafe fn countForObject(&self, object: &ObjectType) -> NSUInteger
pub unsafe fn objectEnumerator(&self) -> Retained<NSEnumerator<ObjectType>>
NSEnumerator
only.pub unsafe fn addObject(&self, object: &ObjectType)
pub unsafe fn removeObject(&self, object: &ObjectType)
source§impl<ObjectType: Message> NSCountedSet<ObjectType>
impl<ObjectType: Message> NSCountedSet<ObjectType>
Methods declared on superclass NSMutableSet
source§impl<ObjectType: Message> NSCountedSet<ObjectType>
impl<ObjectType: Message> NSCountedSet<ObjectType>
Methods declared on superclass NSSet
pub unsafe fn initWithObjects_count( this: Allocated<Self>, objects: *mut NonNull<ObjectType>, cnt: NSUInteger ) -> Retained<Self>
Methods from Deref<Target = NSMutableSet<ObjectType>>§
pub unsafe fn filterUsingPredicate(&mut self, predicate: &NSPredicate)
NSPredicate
only.pub unsafe fn addObject(&mut self, object: &ObjectType)
pub unsafe fn removeObject(&mut self, object: &ObjectType)
pub unsafe fn addObjectsFromArray(&mut self, array: &NSArray<ObjectType>)
NSArray
only.pub unsafe fn intersectSet(&mut self, other_set: &NSSet<ObjectType>)
pub unsafe fn minusSet(&mut self, other_set: &NSSet<ObjectType>)
pub fn removeAllObjects(&mut self)
pub unsafe fn unionSet(&mut self, other_set: &NSSet<ObjectType>)
pub unsafe fn setSet(&mut self, other_set: &NSSet<ObjectType>)
sourcepub fn insert(&mut self, value: &T) -> boolwhere
T: HasStableHash + IsRetainable,
pub fn insert(&mut self, value: &T) -> boolwhere
T: HasStableHash + IsRetainable,
Add a value to the set. Returns whether the value was newly inserted.
§Examples
use objc2_foundation::{NSNumber, NSMutableSet};
let mut set = NSMutableSet::new();
assert_eq!(set.insert(&*NSNumber::new_u32(42)), true);
assert_eq!(set.insert(&*NSNumber::new_u32(42)), false);
assert_eq!(set.len(), 1);
sourcepub fn insert_id(&mut self, value: Retained<T>) -> boolwhere
T: HasStableHash,
pub fn insert_id(&mut self, value: Retained<T>) -> boolwhere
T: HasStableHash,
Add an Retained
to the set. Returns whether the value was
newly inserted.
§Examples
use objc2_foundation::{NSMutableSet, NSString};
let mut set = NSMutableSet::new();
assert_eq!(set.insert_id(NSString::from_str("one")), true);
assert_eq!(set.insert_id(NSString::from_str("one")), false);
assert_eq!(set.len(), 1);
sourcepub fn remove(&mut self, value: &T) -> boolwhere
T: HasStableHash,
pub fn remove(&mut self, value: &T) -> boolwhere
T: HasStableHash,
Removes a value from the set. Returns whether the value was present in the set.
§Examples
use objc2_foundation::{ns_string, NSMutableSet, NSString};
let mut set = NSMutableSet::new();
set.insert_id(NSString::from_str("one"));
assert_eq!(set.remove(ns_string!("one")), true);
assert_eq!(set.remove(ns_string!("one")), false);
Methods from Deref<Target = NSSet<ObjectType>>§
pub unsafe fn valueForKey(&self, key: &NSString) -> Retained<AnyObject>
NSKeyValueCoding
and NSString
only.pub unsafe fn setValue_forKey(&self, value: Option<&AnyObject>, key: &NSString)
NSKeyValueCoding
and NSString
only.pub unsafe fn addObserver_forKeyPath_options_context( &self, observer: &NSObject, key_path: &NSString, options: NSKeyValueObservingOptions, context: *mut c_void )
NSKeyValueObserving
and NSString
only.pub unsafe fn removeObserver_forKeyPath_context( &self, observer: &NSObject, key_path: &NSString, context: *mut c_void )
NSKeyValueObserving
and NSString
only.pub unsafe fn removeObserver_forKeyPath( &self, observer: &NSObject, key_path: &NSString )
NSKeyValueObserving
and NSString
only.pub unsafe fn filteredSetUsingPredicate( &self, predicate: &NSPredicate ) -> Retained<NSSet<ObjectType>>
NSPredicate
only.pub fn count(&self) -> NSUInteger
pub unsafe fn member(&self, object: &ObjectType) -> Option<Retained<ObjectType>>
pub unsafe fn objectEnumerator(&self) -> Retained<NSEnumerator<ObjectType>>
NSEnumerator
only.pub unsafe fn allObjects(&self) -> Retained<NSArray<ObjectType>>
NSArray
only.pub unsafe fn anyObject(&self) -> Option<Retained<ObjectType>>
pub unsafe fn containsObject(&self, an_object: &ObjectType) -> bool
pub unsafe fn description(&self) -> Retained<NSString>
NSString
only.pub unsafe fn descriptionWithLocale( &self, locale: Option<&AnyObject> ) -> Retained<NSString>
NSString
only.pub unsafe fn intersectsSet(&self, other_set: &NSSet<ObjectType>) -> bool
pub unsafe fn isEqualToSet(&self, other_set: &NSSet<ObjectType>) -> bool
pub unsafe fn isSubsetOfSet(&self, other_set: &NSSet<ObjectType>) -> bool
pub unsafe fn makeObjectsPerformSelector(&self, a_selector: Sel)
pub unsafe fn makeObjectsPerformSelector_withObject( &self, a_selector: Sel, argument: Option<&AnyObject> )
pub unsafe fn setByAddingObject( &self, an_object: &ObjectType ) -> Retained<NSSet<ObjectType>>
pub unsafe fn setByAddingObjectsFromSet( &self, other: &NSSet<ObjectType> ) -> Retained<NSSet<ObjectType>>
pub unsafe fn setByAddingObjectsFromArray( &self, other: &NSArray<ObjectType> ) -> Retained<NSSet<ObjectType>>
NSArray
only.pub unsafe fn enumerateObjectsUsingBlock( &self, block: &Block<dyn Fn(NonNull<ObjectType>, NonNull<Bool>) + '_> )
block2
only.pub unsafe fn enumerateObjectsWithOptions_usingBlock( &self, opts: NSEnumerationOptions, block: &Block<dyn Fn(NonNull<ObjectType>, NonNull<Bool>) + '_> )
NSObjCRuntime
and block2
only.pub unsafe fn objectsPassingTest( &self, predicate: &Block<dyn Fn(NonNull<ObjectType>, NonNull<Bool>) -> Bool + '_> ) -> Retained<NSSet<ObjectType>>
block2
only.pub unsafe fn objectsWithOptions_passingTest( &self, opts: NSEnumerationOptions, predicate: &Block<dyn Fn(NonNull<ObjectType>, NonNull<Bool>) -> Bool + '_> ) -> Retained<NSSet<ObjectType>>
NSObjCRuntime
and block2
only.pub unsafe fn sortedArrayUsingDescriptors( &self, sort_descriptors: &NSArray<NSSortDescriptor> ) -> Retained<NSArray<ObjectType>>
NSSortDescriptor
and NSArray
only.sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of elements in the set.
§Examples
use objc2_foundation::{NSSet, NSString};
let strs = ["one", "two", "three"].map(NSString::from_str);
let set = NSSet::from_id_slice(&strs);
assert_eq!(set.len(), 3);
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if the set contains no elements.
§Examples
use objc2_foundation::{NSSet, NSString};
let set = NSSet::<NSString>::new();
assert!(set.is_empty());
sourcepub fn to_vec(&self) -> Vec<&T>
Available on crate feature NSEnumerator
only.
pub fn to_vec(&self) -> Vec<&T>
NSEnumerator
only.Returns a Vec
containing the set’s elements.
§Examples
use objc2_foundation::{NSMutableString, NSSet};
let strs = vec![
NSMutableString::from_str("one"),
NSMutableString::from_str("two"),
NSMutableString::from_str("three"),
];
let set = NSSet::from_vec(strs);
let vec = set.to_vec();
assert_eq!(vec.len(), 3);
pub fn to_vec_retained(&self) -> Vec<Retained<T>>where
T: IsIdCloneable,
NSEnumerator
only.sourcepub fn to_array(&self) -> Retained<NSArray<T>>where
T: IsIdCloneable,
Available on crate feature NSArray
only.
pub fn to_array(&self) -> Retained<NSArray<T>>where
T: IsIdCloneable,
NSArray
only.Returns an NSArray
containing the set’s elements, or an empty
array if the set is empty.
§Examples
use objc2_foundation::{NSNumber, NSSet, NSString};
let nums = [1, 2, 3];
let set = NSSet::from_id_slice(&nums.map(NSNumber::new_i32));
assert_eq!(set.to_array().len(), 3);
assert!(set.to_array().iter().all(|i| nums.contains(&i.as_i32())));
sourcepub fn get_any(&self) -> Option<&T>
pub fn get_any(&self) -> Option<&T>
Returns a reference to one of the objects in the set, or None
if
the set is empty.
§Examples
use objc2_foundation::{NSSet, NSString};
let strs = ["one", "two", "three"].map(NSString::from_str);
let set = NSSet::from_id_slice(&strs);
let any = set.get_any().unwrap();
assert!(any == &*strs[0] || any == &*strs[1] || any == &*strs[2]);
sourcepub fn contains(&self, value: &T) -> bool
pub fn contains(&self, value: &T) -> bool
Returns true
if the set contains a value.
§Examples
use objc2_foundation::{ns_string, NSSet, NSString};
let strs = ["one", "two", "three"].map(NSString::from_str);
let set = NSSet::from_id_slice(&strs);
assert!(set.contains(ns_string!("one")));
sourcepub fn get(&self, value: &T) -> Option<&T>
pub fn get(&self, value: &T) -> Option<&T>
Returns a reference to the value in the set, if any, that is equal to the given value.
§Examples
use objc2_foundation::{ns_string, NSSet, NSString};
let strs = ["one", "two", "three"].map(NSString::from_str);
let set = NSSet::from_id_slice(&strs);
assert_eq!(set.get(ns_string!("one")), Some(&*strs[0]));
assert_eq!(set.get(ns_string!("four")), None);
pub fn get_retained(&self, value: &T) -> Option<Retained<T>>where
T: IsIdCloneable,
sourcepub fn is_subset(&self, other: &NSSet<T>) -> bool
pub fn is_subset(&self, other: &NSSet<T>) -> bool
Returns true
if the set is a subset of another, i.e., other
contains at least all the values in self
.
§Examples
use objc2_foundation::{NSSet, NSString};
let set1 = NSSet::from_id_slice(&["one", "two"].map(NSString::from_str));
let set2 = NSSet::from_id_slice(&["one", "two", "three"].map(NSString::from_str));
assert!(set1.is_subset(&set2));
assert!(!set2.is_subset(&set1));
sourcepub fn is_superset(&self, other: &NSSet<T>) -> bool
pub fn is_superset(&self, other: &NSSet<T>) -> bool
Returns true
if the set is a superset of another, i.e., self
contains at least all the values in other
.
§Examples
use objc2_foundation::{NSSet, NSString};
let set1 = NSSet::from_id_slice(&["one", "two"].map(NSString::from_str));
let set2 = NSSet::from_id_slice(&["one", "two", "three"].map(NSString::from_str));
assert!(!set1.is_superset(&set2));
assert!(set2.is_superset(&set1));
sourcepub fn is_disjoint(&self, other: &NSSet<T>) -> bool
pub fn is_disjoint(&self, other: &NSSet<T>) -> bool
Returns true
if self
has no elements in common with other
.
§Examples
use objc2_foundation::{NSSet, NSString};
let set1 = NSSet::from_id_slice(&["one", "two"].map(NSString::from_str));
let set2 = NSSet::from_id_slice(&["one", "two", "three"].map(NSString::from_str));
let set3 = NSSet::from_id_slice(&["four", "five", "six"].map(NSString::from_str));
assert!(!set1.is_disjoint(&set2));
assert!(set1.is_disjoint(&set3));
assert!(set2.is_disjoint(&set3));
sourcepub fn iter(&self) -> Iter<'_, T> ⓘ
Available on crate feature NSEnumerator
only.
pub fn iter(&self) -> Iter<'_, T> ⓘ
NSEnumerator
only.An iterator visiting all elements in arbitrary order.
§Examples
use objc2_foundation::{NSSet, NSString};
let strs = ["one", "two", "three"].map(NSString::from_str);
let set = NSSet::from_id_slice(&strs);
for s in &set {
println!("{s}");
}
pub fn iter_retained(&self) -> IterRetained<'_, T> ⓘwhere
T: IsIdCloneable,
NSEnumerator
only.Methods from Deref<Target = NSObject>§
sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
sourcepub fn class(&self) -> &'static AnyClass
pub fn class(&self) -> &'static AnyClass
Dynamically find the class of this object.
§Example
Check that an instance of NSObject
has the precise class NSObject
.
use objc2::ClassType;
use objc2::runtime::NSObject;
let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());
sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load
instead.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
Ivar::load
instead.Use Ivar::load
instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T
.
See Ivar::load_ptr
for details surrounding this.
sourcepub unsafe fn get_mut_ivar<T>(&mut self, name: &str) -> &mut Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load_mut
instead.
pub unsafe fn get_mut_ivar<T>(&mut self, name: &str) -> &mut Twhere
T: Encode,
Ivar::load_mut
instead.Use Ivar::load_mut
instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T
.
See Ivar::load_ptr
for details surrounding this.
Trait Implementations§
source§impl<ObjectType: ?Sized + Message> AsMut<NSCountedSet<ObjectType>> for NSCountedSet<ObjectType>
impl<ObjectType: ?Sized + Message> AsMut<NSCountedSet<ObjectType>> for NSCountedSet<ObjectType>
source§impl<ObjectType: ?Sized + Message> AsMut<NSMutableSet<ObjectType>> for NSCountedSet<ObjectType>
impl<ObjectType: ?Sized + Message> AsMut<NSMutableSet<ObjectType>> for NSCountedSet<ObjectType>
source§fn as_mut(&mut self) -> &mut NSMutableSet<ObjectType>
fn as_mut(&mut self) -> &mut NSMutableSet<ObjectType>
source§impl<ObjectType: ?Sized + Message> AsRef<NSCountedSet<ObjectType>> for NSCountedSet<ObjectType>
impl<ObjectType: ?Sized + Message> AsRef<NSCountedSet<ObjectType>> for NSCountedSet<ObjectType>
source§impl<ObjectType: ?Sized + Message> AsRef<NSMutableSet<ObjectType>> for NSCountedSet<ObjectType>
impl<ObjectType: ?Sized + Message> AsRef<NSMutableSet<ObjectType>> for NSCountedSet<ObjectType>
source§fn as_ref(&self) -> &NSMutableSet<ObjectType>
fn as_ref(&self) -> &NSMutableSet<ObjectType>
source§impl<ObjectType: ?Sized + Message> Borrow<NSMutableSet<ObjectType>> for NSCountedSet<ObjectType>
impl<ObjectType: ?Sized + Message> Borrow<NSMutableSet<ObjectType>> for NSCountedSet<ObjectType>
source§fn borrow(&self) -> &NSMutableSet<ObjectType>
fn borrow(&self) -> &NSMutableSet<ObjectType>
source§impl<ObjectType: ?Sized + Message> BorrowMut<AnyObject> for NSCountedSet<ObjectType>
impl<ObjectType: ?Sized + Message> BorrowMut<AnyObject> for NSCountedSet<ObjectType>
source§fn borrow_mut(&mut self) -> &mut AnyObject
fn borrow_mut(&mut self) -> &mut AnyObject
source§impl<ObjectType: ?Sized + Message> BorrowMut<NSMutableSet<ObjectType>> for NSCountedSet<ObjectType>
impl<ObjectType: ?Sized + Message> BorrowMut<NSMutableSet<ObjectType>> for NSCountedSet<ObjectType>
source§fn borrow_mut(&mut self) -> &mut NSMutableSet<ObjectType>
fn borrow_mut(&mut self) -> &mut NSMutableSet<ObjectType>
source§impl<ObjectType: ?Sized + Message> BorrowMut<NSObject> for NSCountedSet<ObjectType>
impl<ObjectType: ?Sized + Message> BorrowMut<NSObject> for NSCountedSet<ObjectType>
source§fn borrow_mut(&mut self) -> &mut NSObject
fn borrow_mut(&mut self) -> &mut NSObject
source§impl<ObjectType: ?Sized + Message> BorrowMut<NSSet<ObjectType>> for NSCountedSet<ObjectType>
impl<ObjectType: ?Sized + Message> BorrowMut<NSSet<ObjectType>> for NSCountedSet<ObjectType>
source§fn borrow_mut(&mut self) -> &mut NSSet<ObjectType>
fn borrow_mut(&mut self) -> &mut NSSet<ObjectType>
source§impl<ObjectType: ?Sized + Message> ClassType for NSCountedSet<ObjectType>
impl<ObjectType: ?Sized + Message> ClassType for NSCountedSet<ObjectType>
§type Super = NSMutableSet<ObjectType>
type Super = NSMutableSet<ObjectType>
§type Mutability = Mutable
type Mutability = Mutable
source§const NAME: &'static str = "NSCountedSet"
const NAME: &'static str = "NSCountedSet"
source§fn class() -> &'static AnyClass
fn class() -> &'static AnyClass
source§fn as_super_mut(&mut self) -> &mut Self::Super
fn as_super_mut(&mut self) -> &mut Self::Super
source§impl<T: Debug + Message> Debug for NSCountedSet<T>
Available on crate feature NSEnumerator
only.
impl<T: Debug + Message> Debug for NSCountedSet<T>
NSEnumerator
only.source§impl<ObjectType: PartialEq + ?Sized> PartialEq for NSCountedSet<ObjectType>
impl<ObjectType: PartialEq + ?Sized> PartialEq for NSCountedSet<ObjectType>
source§fn eq(&self, other: &NSCountedSet<ObjectType>) -> bool
fn eq(&self, other: &NSCountedSet<ObjectType>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<ObjectType: ?Sized + Message> RefEncode for NSCountedSet<ObjectType>
impl<ObjectType: ?Sized + Message> RefEncode for NSCountedSet<ObjectType>
source§const ENCODING_REF: Encoding = <NSMutableSet<ObjectType> as ::objc2::RefEncode>::ENCODING_REF
const ENCODING_REF: Encoding = <NSMutableSet<ObjectType> as ::objc2::RefEncode>::ENCODING_REF
impl<ObjectType: Eq + ?Sized> Eq for NSCountedSet<ObjectType>
impl<ObjectType: ?Sized + Message> Message for NSCountedSet<ObjectType>
impl<ObjectType: ?Sized + NSCoding> NSCoding for NSCountedSet<ObjectType>
NSObject
only.impl<ObjectType: ?Sized + IsIdCloneable> NSCopying for NSCountedSet<ObjectType>
NSObject
only.impl<ObjectType: ?Sized> NSFastEnumeration for NSCountedSet<ObjectType>
NSEnumerator
only.impl<ObjectType: ?Sized + IsIdCloneable> NSMutableCopying for NSCountedSet<ObjectType>
NSObject
only.impl<ObjectType: ?Sized> NSObjectProtocol for NSCountedSet<ObjectType>
impl<ObjectType: ?Sized + NSSecureCoding> NSSecureCoding for NSCountedSet<ObjectType>
NSObject
only.