# Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license # found at http://www.opensource.org/licenses/mit-license.html ................ statics ? def makeConstSet := # value: old: ? def Set := makeConstSet.asType() ? Set # value: ? Set == makeConstSet.asType() # value: true maker methods and sets for further testing ? def oneSet := makeConstSet.fromKeysOf([1 => 2]) # value: [1].asSet() ? def emptySet := makeConstSet.getEmptySet() # value: [].asSet() ? def threeSet := makeConstSet.fromKeysOf([1 => 2, 3 => 4, 5 => 6]) # value: [1, 3, 5].asSet() guard ? oneSet :Set # value: [1].asSet() ? emptySet :Set # value: [].asSet() ? [] :Set # problem: not a ConstSet: [] sameness ? threeSet == makeConstSet.fromKeysOf([1 => 2, 3 => 4, 5 => 6]) # value: true ? threeSet == makeConstSet.fromKeysOf([1 => 'a', 3 => 2, 5 => {def a;a}]) # value: true __optUncall ? oneSet.__optUncall() # value: [[1], "asSet", []] iterate ? for item in threeSet { print(item) } # stdout: 135 snapshot ? oneSet.snapshot() # value: [1].asSet() printOn ? threeSet.printOn("a", "b", "c", stdout) # stdout: a1b3b5c size ? threeSet.size() # value: 3 getElements ? threeSet.getElements() # value: [1, 3, 5] butNot ? threeSet &! oneSet # value: [5, 3].asSet() XXX coercion of argument with ? threeSet.with(7) # value: [1, 3, 5, 7].asSet() ? threeSet.with(3) # value: [1, 3, 5].asSet() without ? threeSet.without(1) # value: [5, 3].asSet() elementType ? threeSet.elementType() # value: any contains ? threeSet.contains(1) # value: true ? threeSet.contains(2) # value: false and ? threeSet & makeConstSet.fromKeysOf([1 => null, 2 => null]) # value: [1].asSet() or ? threeSet | makeConstSet.fromKeysOf([1 => null, 2 => null]) # value: [1, 2, 3, 5].asSet() ? threeSet.or(makeConstSet.fromKeysOf([1 => null, 2 => null]), false) # value: [1, 2, 3, 5].asSet() ? threeSet.or(makeConstSet.fromKeysOf([1 => null, 2 => null]), true) # problem: both sets contain 1, in strict union of [1, 3, 5].asSet() and [1, 2].asSet() readOnly ? threeSet.readOnly() == threeSet # value: true sort ? [].asSet().sort() # value: [].asSet() ? [3,7,2,6,3].asSet().sort() # value: [2, 3, 6, 7].asSet() XXX sort/1 XXX sameness XXX diverge/1,2 XXX should we have getElements/1 at all? XXX op__cmp/1 XXX intersects/1