ISet.Add(Object) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Adds the specified element to this set if it is not already present (optional operation).
[Android.Runtime.Register("add", "(Ljava/lang/Object;)Z", "GetAdd_Ljava_lang_Object_Handler:Java.Util.ISetInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")]
public bool Add (Java.Lang.Object? e);
[<Android.Runtime.Register("add", "(Ljava/lang/Object;)Z", "GetAdd_Ljava_lang_Object_Handler:Java.Util.ISetInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")>]
abstract member Add : Java.Lang.Object -> bool
Parameters
- e
- Object
element to be added to this set
Returns
true
if this set did not already contain the specified
element
Implements
- Attributes
Remarks
Adds the specified element to this set if it is not already present (optional operation). More formally, adds the specified element e
to this set if the set contains no element e2
such that Objects.equals(e, e2)
. If this set already contains the element, the call leaves the set unchanged and returns false
. In combination with the restriction on constructors, this ensures that sets never contain duplicate elements.
The stipulation above does not imply that sets must accept all elements; sets may refuse to add any particular element, including null
, and throw an exception, as described in the specification for Collection#add Collection.add
. Individual set implementations should clearly document any restrictions on the elements that they may contain.
Java documentation for java.util.Set.add(E)
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.