Package com.dd.plist

Class NSSet

All Implemented Interfaces:
Cloneable, Comparable<NSObject>

public class NSSet extends NSObject
The NSSet class is an unordered collection of NSObject instances. This implementation uses a LinkedHashSet or TreeSetas the underlying data structure.
Author:
Daniel Dreibrodt
See Also:
  • Constructor Details

    • NSSet

      public NSSet()
      Creates a new NSSet instance. The created set is unordered.
      See Also:
    • NSSet

      public NSSet(boolean ordered)
      Creates a new NSSet instance.
      Parameters:
      ordered - Indicates whether the created set should be ordered or unordered.
      See Also:
    • NSSet

      public NSSet(NSObject... objects)
      Creates a new NSSet instance with the specified content. The created set is unordered.
      Parameters:
      objects - The objects to populate the set.
      See Also:
    • NSSet

      public NSSet(boolean ordered, NSObject... objects)
      Create a new NSSet instance with the specified content.
      Parameters:
      ordered - Indicates whether the created set should be ordered or unordered.
      objects - The objects to populate the set.
      See Also:
  • Method Details

    • addObject

      public void addObject(NSObject obj)
      Adds an object to the set.
      Parameters:
      obj - The object to add.
    • removeObject

      public void removeObject(NSObject obj)
      Removes an object from the set.
      Parameters:
      obj - The object to remove.
    • allObjects

      public NSObject[] allObjects()
      Returns all objects contained in the set.
      Returns:
      An array of all objects in the set.
    • anyObject

      public NSObject anyObject()
      Returns one of the objects in the set, or null if the set contains no objects.
      Returns:
      The first object in the set, or null if the set is empty.
    • containsObject

      public boolean containsObject(NSObject obj)
      Finds out whether the given object is contained in the set.
      Parameters:
      obj - The object to look for.
      Returns:
      true, when the object was found, false otherwise.
    • member

      public NSObject member(NSObject obj)
      Determines whether the set contains an object equal to the given object and returns that object if it is present.
      Parameters:
      obj - The object to look for.
      Returns:
      The object if it is present, null otherwise.
    • intersectsSet

      public boolean intersectsSet(NSSet otherSet)
      Finds out whether at least one object is present in both sets.
      Parameters:
      otherSet - The other set.
      Returns:
      false if the intersection of both sets is empty, true otherwise.
    • isSubsetOfSet

      public boolean isSubsetOfSet(NSSet otherSet)
      Finds out if this set is a subset of the given set.
      Parameters:
      otherSet - The other set.
      Returns:
      true if all elements in this set are also present in the other set, false otherwise.
    • objectIterator

      public Iterator<NSObject> objectIterator()
      Returns an iterator object that lets you iterate over all elements of the set. This is the equivalent to objectEnumerator in the Cocoa implementation of NSSet.
      Returns:
      The iterator for the set.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • compareTo

      public int compareTo(NSObject o)
    • count

      public int count()
      Gets the number of elements in the set.
      Returns:
      The number of elements in the set.
      See Also:
    • clone

      public NSSet clone()
      Description copied from class: NSObject
      Creates and returns a deep copy of this instance.
      Specified by:
      clone in class NSObject
      Returns:
      A clone of this instance.
    • toJavaObject

      public Object toJavaObject()
      Description copied from class: NSObject
      Converts this NSObject into an equivalent object of the Java Runtime Environment.
      • NSArray objects are converted to arrays.
      • NSDictionary objects are converted to objects extending the Map class.
      • NSSet objects are converted to objects extending the Set class.
      • NSNumber objects are converted to primitive number values (int, long, double or boolean).
      • NSString objects are converted to String objects.
      • NSData objects are converted to byte arrays.
      • NSDate objects are converted to Date objects.
      • UID objects are converted to byte arrays.
      Specified by:
      toJavaObject in class NSObject
      Returns:
      A native java object representing this NSObject's value.