123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- /*
- * Copyright (C)2005-2019 Haxe Foundation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
- package js.lib;
- import js.lib.Map.MapEntry;
- import js.lib.Iterator;
- /**
- The `js.Set` object lets you store unique values of any type, whether
- primitive values or object references.
- Documentation [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
- **/
- @:native("Set")
- extern class Set<T> {
- /**
- The number of values in the `js.Set` object.
- **/
- var size(default, null):Int;
- /**
- If an iterable object is passed, all of its elements will be added to
- the new `js.Set`.
- **/
- @:pure function new(?iterable:Any);
- /**
- Returns a boolean asserting whether an element is present with the given
- value in the `js.Set` object or not.
- **/
- @:pure function has(value:T):Bool;
- /**
- Appends a new element with the given value to the `js.Set` object.
- Returns the `js.Set` object.
- **/
- function add(value:T):Set<T>;
- /**
- Removes the element associated to the value and returns the value that
- `has(value)` would have previously returned.
- `has(value)` will return `false` afterwards.
- **/
- function delete(value:T):Bool;
- /**
- Removes all elements from the `js.Set` object.
- **/
- function clear():Void;
- /**
- Calls `callback` once for each key-value pair present in the `js.Set`
- object, in insertion order.
- If a `thisArg` parameter is provided to forEach, it will be used as the
- `this` value for each callback.
- **/
- function forEach(callback:(value:T, key:T, set:Set<T>) -> Void, ?thisArg:Any):Void;
- /**
- Returns a new `js.lib.Iterator` object that contains the keys for each element
- in the `js.Set` object in insertion order.
- **/
- function keys():Iterator<T>;
- /**
- Returns a new `js.lib.Iterator` object that contains the values for each
- element in the `js.Set` object in insertion order.
- **/
- function values():Iterator<T>;
- /**
- Returns a new `js.lib.Iterator` object that contains an array of
- `[value, value]` for each element in the `js.Set` object, in insertion
- order.
- This is kept similar to the `js.Map` object, so that each entry has the
- same value for its key and value here.
- **/
- function entries():Iterator<MapEntry<T, T>>;
- }
|