AI2 Component  (Version nb184)
Sets.java
Go to the documentation of this file.
1 // -*- mode: java; c-basic-offset: 2; -*-
2 // Copyright 2009-2011 Google, All Rights reserved
3 // Copyright 2011-2012 MIT, All rights reserved
4 // Released under the Apache License, Version 2.0
5 // http://www.apache.org/licenses/LICENSE-2.0
6 
7 package com.google.appinventor.components.runtime.collect;
8 
9 import java.util.Collections;
10 import java.util.EnumSet;
11 import java.util.HashSet;
12 import java.util.SortedSet;
13 import java.util.TreeSet;
14 
23 public class Sets {
24 
36  public static <K> HashSet<K> newHashSet() {
37  return new HashSet<K>();
38  }
39 
57  public static <E> HashSet<E> newHashSet(E... elements) {
58  int capacity = elements.length * 4 / 3 + 1;
59  HashSet<E> set = new HashSet<E>(capacity);
60  Collections.addAll(set, elements);
61  return set;
62  }
63 
71  public static <E> SortedSet<E> newSortedSet(E... elements) {
72  SortedSet<E> set = new TreeSet<E>();
73  Collections.addAll(set, elements);
74  return set;
75  }
76 }
com.google.appinventor.components.runtime.collect.Sets.newHashSet
static< K > HashSet< K > newHashSet()
Definition: Sets.java:36
com.google.appinventor.components.runtime.collect.Sets.newSortedSet
static< E > SortedSet< E > newSortedSet(E... elements)
Definition: Sets.java:71
com.google.appinventor.components.runtime.collect.Sets.newHashSet
static< E > HashSet< E > newHashSet(E... elements)
Definition: Sets.java:57
com.google.appinventor.components.runtime.collect.Sets
Definition: Sets.java:23