2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,21 +1,22 @@
|
|||
def list = [1, 2, 3, 'a', 'b', 'c', 2, 3, 4, 'b', 'c', 'd']
|
||||
assert list.size() == 12
|
||||
println " Original List: ${list}"
|
||||
println " Original List: ${list}"
|
||||
|
||||
// Filtering the List
|
||||
// Filtering the List (non-mutating)
|
||||
def list2 = list.unique(false)
|
||||
assert list2.size() == 8
|
||||
assert list.size() == 12
|
||||
println " Filtered List: ${list2}"
|
||||
|
||||
// Filtering the List (in place)
|
||||
list.unique()
|
||||
assert list.size() == 8
|
||||
println " Filtered List: ${list}"
|
||||
println " Original List, filtered: ${list}"
|
||||
|
||||
list = [1, 2, 3, 'a', 'b', 'c', 2, 3, 4, 'b', 'c', 'd']
|
||||
assert list.size() == 12
|
||||
def list3 = [1, 2, 3, 'a', 'b', 'c', 2, 3, 4, 'b', 'c', 'd']
|
||||
assert list3.size() == 12
|
||||
|
||||
// Converting to Set
|
||||
def set = new HashSet(list)
|
||||
def set = list as Set
|
||||
assert set.size() == 8
|
||||
println " Set: ${set}"
|
||||
|
||||
// Converting to Order-preserving Set
|
||||
set = new LinkedHashSet(list)
|
||||
assert set.size() == 8
|
||||
println "List-ordered Set: ${set}"
|
||||
println " Set: ${set}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue