Tabnine Logo
Set.toArray
Code IndexAdd Tabnine to your IDE (free)

How to use
toArray
method
in
java.util.Set

Best Java code snippets using java.util.Set.toArray (Showing top 20 results out of 50,958)

Refine searchRefine arrow

  • Set.size
  • Set.add
  • Map.keySet
  • Map.size
  • Map.get
  • Set.isEmpty
  • Set.addAll
  • Arrays.asList
origin: spring-projects/spring-framework

public String[] getAttributeNames() {
  return this.attributes.keySet().toArray(new String[0]);
}
origin: libgdx/libgdx

public Class[] getInterfaces() {
  return interfaces.toArray(new Class[this.interfaces.size()]);
}
origin: spring-projects/spring-framework

public static Method[] getPropertyMethods(PropertyDescriptor[] properties, boolean read, boolean write) {
  Set methods = new HashSet();
  for (int i = 0; i < properties.length; i++) {
    PropertyDescriptor pd = properties[i];
    if (read) {
      methods.add(pd.getReadMethod());
    }
    if (write) {
      methods.add(pd.getWriteMethod());
    }
  }
  methods.remove(null);
  return (Method[]) methods.toArray(new Method[methods.size()]);
}
origin: google/j2objc

public AddPropertyTransformer(Map props) {
  int size = props.size();
  names = (String[])props.keySet().toArray(new String[size]);
  types = new Type[size];
  for (int i = 0; i < size; i++) {
    types[i] = (Type)props.get(names[i]);
  }
}
origin: google/guava

 @Override
 TypeVariable<?> captureAsTypeVariable(Type[] upperBounds) {
  Set<Type> combined = new LinkedHashSet<>(asList(upperBounds));
  // Since this is an artifically generated type variable, we don't bother checking
  // subtyping between declared type bound and actual type bound. So it's possible that we
  // may generate something like <capture#1-of ? extends Foo&SubFoo>.
  // Checking subtype between declared and actual type bounds
  // adds recursive isSubtypeOf() call and feels complicated.
  // There is no contract one way or another as long as isSubtypeOf() works as expected.
  combined.addAll(asList(typeParam.getBounds()));
  if (combined.size() > 1) { // Object is implicit and only useful if it's the only bound.
   combined.remove(Object.class);
  }
  return super.captureAsTypeVariable(combined.toArray(new Type[0]));
 }
};
origin: robolectric/robolectric

@Implementation
protected @Nullable String[] getPackagesForUid(int uid) {
 String[] packageNames = packagesForUid.get(uid);
 if (packageNames != null) {
  return packageNames;
 }
 Set<String> results = new HashSet<>();
 for (PackageInfo packageInfo : packageInfos.values()) {
  if (packageInfo.applicationInfo != null && packageInfo.applicationInfo.uid == uid) {
   results.add(packageInfo.packageName);
  }
 }
 return results.isEmpty() ? null : results.toArray(new String[results.size()]);
}
origin: google/guava

Set<K> keySet = map.keySet();
Collection<V> valueCollection = map.values();
Set<Entry<K, V>> entrySet = map.entrySet();
 V value = map.get(key);
 expectedKeySetHash += key != null ? key.hashCode() : 0;
 assertTrue(map.containsKey(key));
assertEquals(map.size(), valueCollection.size());
assertEquals(valueCollection.size() == 0, valueCollection.isEmpty());
assertEquals(!valueCollection.isEmpty(), valueCollection.iterator().hasNext());
Object[] entrySetToArray1 = entrySet.toArray();
assertEquals(map.size(), entrySetToArray1.length);
assertTrue(Arrays.asList(entrySetToArray1).containsAll(entrySet));
Entry<?, ?>[] entrySetToArray2 = new Entry<?, ?>[map.size() + 2];
entrySetToArray2[map.size()] = mapEntry("foo", 1);
assertSame(entrySetToArray2, entrySet.toArray(entrySetToArray2));
assertNull(entrySetToArray2[map.size()]);
assertTrue(Arrays.asList(entrySetToArray2).containsAll(entrySet));
assertEquals(map.size(), valuesToArray1.length);
assertTrue(Arrays.asList(valuesToArray1).containsAll(valueCollection));
Object[] valuesToArray2 = new Object[map.size() + 2];
origin: robolectric/robolectric

@Override
public int getAvailableRestoreSets(IRestoreObserver observer, IBackupManagerMonitor monitor)
  throws RemoteException {
 post(
   () -> {
    Set<Long> restoreTokens = serviceState.restoreData.keySet();
    Set<RestoreSet> restoreSets = new HashSet<>();
    for (long token : restoreTokens) {
     restoreSets.add(new RestoreSet("RestoreSet-" + token, "device", token));
    }
    observer.restoreSetsAvailable(restoreSets.toArray(new RestoreSet[restoreSets.size()]));
   });
 return BackupManager.SUCCESS;
}
origin: apache/flink

/**
 * Returns the names of all registered column families.
 *
 * @return The names of all registered column families.
 */
String[] getFamilyNames() {
  return this.familyMap.keySet().toArray(new String[this.familyMap.size()]);
}
origin: jfinal/jfinal

/**
 * Return attribute names of this model.
 */
public String[] _getAttrNames() {
  Set<String> attrNameSet = attrs.keySet();
  return attrNameSet.toArray(new String[attrNameSet.size()]);
}
 
origin: jMonkeyEngine/jmonkeyengine

public void print(){
  System.out.println("-----------------");
  Set<Integer> keys = objs.keySet();
  Integer[] keysArr = keys.toArray(new Integer[0]);
  Arrays.sort(keysArr);
  for (int i = 0; i < keysArr.length; i++){
    System.out.println(keysArr[i]+" => "+objs.get(keysArr[i]).hashCode());
  }
}
origin: stanfordnlp/CoreNLP

/**
 * dump the {@code <x,y>} pairs it computed found
 */
public void dumpMemory() {
 Double[] keys = memory.keySet().toArray(new Double[memory.keySet().size()]);
 Arrays.sort(keys);
 for (Double key : keys) {
  log.info(key + "\t" + memory.get(key));
 }
}
origin: ben-manes/caffeine

@CheckNoWriter @CheckNoStats
@Test(dataProvider = "caches")
@CacheSpec(removalListener = { Listener.DEFAULT, Listener.REJECTING })
public void keySetToArray(Map<Integer, Integer> map, CacheContext context) {
 int length = context.original().size();
 Integer[] ints = map.keySet().toArray(new Integer[length]);
 assertThat(ints.length, is(length));
 assertThat(Arrays.asList(ints).containsAll(context.original().keySet()), is(true));
 Object[] array = map.keySet().toArray();
 assertThat(array.length, is(length));
 assertThat(Arrays.asList(array).containsAll(context.original().keySet()), is(true));
}
origin: google/guava

/**
 * Returns a new proxy for {@code interfaceType}. Proxies of the same interface are equal to each
 * other if the {@link DummyProxy} instance that created the proxies are equal.
 */
final <T> T newProxy(TypeToken<T> interfaceType) {
 Set<Class<?>> interfaceClasses = Sets.newLinkedHashSet();
 interfaceClasses.addAll(interfaceType.getTypes().interfaces().rawTypes());
 // Make the proxy serializable to work with SerializableTester
 interfaceClasses.add(Serializable.class);
 Object dummy =
   Proxy.newProxyInstance(
     interfaceClasses.iterator().next().getClassLoader(),
     interfaceClasses.toArray(new Class<?>[interfaceClasses.size()]),
     new DummyHandler(interfaceType));
 @SuppressWarnings("unchecked") // interfaceType is T
 T result = (T) dummy;
 return result;
}
origin: ctripcorp/apollo

@Override
public String[] getPropertyNames() {
 Set<String> propertyNames = this.source.getPropertyNames();
 if (propertyNames.isEmpty()) {
  return EMPTY_ARRAY;
 }
 return propertyNames.toArray(new String[propertyNames.size()]);
}
origin: javax.activation/activation

/**
 * Return all the MIME types known to this mailcap file.
 */
public String[] getMimeTypes() {
Set types = new HashSet(type_hash.keySet());
types.addAll(fallback_hash.keySet());
types.addAll(native_commands.keySet());
String[] mts = new String[types.size()];
mts = (String[])types.toArray(mts);
return mts;
}
origin: apache/nifi

private static URL[] combineURLs(final Set<URL> instanceUrls, final Set<URL> additionalResourceUrls) {
  final Set<URL> allUrls = new LinkedHashSet<>();
  if (instanceUrls != null) {
    allUrls.addAll(instanceUrls);
  }
  if (additionalResourceUrls != null) {
    allUrls.addAll(additionalResourceUrls);
  }
  return allUrls.toArray(new URL[allUrls.size()]);
}
origin: stackoverflow.com

 Set<Integer> s1 = new HashSet<Integer>(Arrays.asList(array1));
Set<Integer> s2 = new HashSet<Integer>(Arrays.asList(array2));
s1.retainAll(s2);

Integer[] result = s1.toArray(new Integer[s1.size()]);
origin: spring-projects/spring-security-oauth

  protected OAuth2Authentication getOAuth2Authentication(ClientDetails client, TokenRequest tokenRequest) {
    Map<String, String> params = tokenRequest.getRequestParameters();
    String username = params.containsKey("username") ? params.get("username") : "guest";
    List<GrantedAuthority> authorities = params.containsKey("authorities") ? AuthorityUtils
        .createAuthorityList(OAuth2Utils.parseParameterList(params.get("authorities")).toArray(new String[0]))
        : AuthorityUtils.NO_AUTHORITIES;
    Authentication user = new UsernamePasswordAuthenticationToken(username, "N/A", authorities);
    OAuth2Authentication authentication = new OAuth2Authentication(tokenRequest.createOAuth2Request(client), user);
    return authentication;
  }
}
origin: ben-manes/caffeine

@CheckNoWriter @CheckNoStats
@Test(dataProvider = "caches")
@CacheSpec(removalListener = { Listener.DEFAULT, Listener.REJECTING })
public void entriesToArray(Map<Integer, Integer> map, CacheContext context) {
 int length = context.original().size();
 Object[] ints = map.entrySet().toArray(new Object[length]);
 assertThat(ints.length, is(length));
 assertThat(Arrays.asList(ints).containsAll(context.original().entrySet()), is(true));
 Object[] array = map.entrySet().toArray();
 assertThat(array.length, is(length));
 assertThat(Arrays.asList(array).containsAll(context.original().entrySet()), is(true));
}
java.utilSettoArray

Javadoc

Returns an array containing all elements contained in this set.

Popular methods of Set

  • add
    Adds the specified element to this set if it is not already present (optional operation). More forma
  • contains
    Returns true if this set contains the specified element. More formally, returns true if and only if
  • iterator
  • size
  • isEmpty
    Returns true if this set contains no elements.
  • addAll
    Adds all of the elements in the specified collection to this set if they're not already present (opt
  • remove
    Removes the specified element from this set if it is present (optional operation). More formally, re
  • stream
  • clear
    Removes all of the elements from this set (optional operation). The set will be empty after this cal
  • removeAll
    Removes from this set all of its elements that are contained in the specified collection (optional o
  • forEach
  • equals
    Compares the specified object with this set for equality. Returnstrue if the specified object is als
  • forEach,
  • equals,
  • containsAll,
  • retainAll,
  • hashCode,
  • removeIf,
  • parallelStream,
  • spliterator,
  • of

Popular in Java

  • Creating JSON documents from java classes using gson
  • compareTo (BigDecimal)
  • getResourceAsStream (ClassLoader)
  • getExternalFilesDir (Context)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • Kernel (java.awt.image)
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now