Version 1 (modified by jaegs, 12 years ago) |
---|
interface ISet def addRange(items as IEnumerable<of T>) def clone def difference(s as ISet<of T>) def intersection(s as ISet<of T>) def isSubsetOf(s as ISet<of T>) def isSupersetOf(s as ISet<of T>) def symmetricDifference(s as ISet<of T>) def toList def union(s as ISet<of T>) class Set """ A Set holds a hashed, unordered collections of items. Membership testing and set operations (intersection, union, etc.) are faster than with lists, but order is not preserved. Set implements ICollection, so it has the usual collection operations such as `add`, `count` and `contains`. It also has set specific operations including `union`, `intersection` and `isSubsetOf`. As with other collections, to create a copy of a set, create a new one passing the original to the initializer: s = Set<of int>(s) TODO: [-] List style items [ ] Can the methods use .getType instead of hardcoding Set? Then subclasses would get created for example .intersection [ ] could use an indexer: s[key]. Does it return bool or T? like NSSet? [ ] Test without args: s = Set(s) (test in C# too) [ ] yielded versions of Set operators? [ ] unit test CobraCore.toTechString() results [ ] ReadOnlySet? [ ] Move some method implementations up to ISet extension """ shared const defaultCapacity = 8 (as int) var _data as Dictionary<of T, T> cue init cue init(comparer as IEqualityComparer<of T>) cue init(items as IEnumerable<of T>) cue init(capacity as int) cue init(items as IEnumerable<of T>?, comparer as IEqualityComparer<of T>?) cue init(capacity as int, items as IEnumerable<of T>?, comparer as IEqualityComparer<of T>?) get count as int get countOfISet as int get isReadOnly as bool def add(item as T) def addRange(items as ISet<of T>) def addRange(items as IEnumerable<of T>) def clear def clone """ Returns a new set with the contents of this set. Does not clone the contents themselves. This is sometimes known as a "shallow copy". """ def contains(item as Object) def contains(item as T) def copyTo(array as T[], arrayIndex as int) def difference(s as ISet<of T>) """ Returns a new set with elements in this set that are not in `s`. """ def equals(other as Object?) def getEnumerator def getEnumerator def getHashCode def intersection(s as ISet<of T>) """ Returns a new set containing only the elements that are in this set and `s`. (AND) """ def isSubsetOf(s as ISet<of T>) def isSupersetOf(s as ISet<of T>) def remove(item as T) def symmetricDifference(s as ISet<of T>) """ Returns a new set with elements in either s or t but not both. (XOR) """ def toList def union(s as ISet<of T>) """ Returns a new set containing the elements of that are in this set or `s`. (OR) """ interface ISet """ This interface is to facilitate Set<of>.equals when the generic types are different (which does not necessarily restrict the two sets from having the same contents). Use ISet<of T> instead. """ get countOfISet as int def contains(item as Object)
Browse source - Set.cobra