本文整理汇总了Java中java.util.Set.toArray方法的典型用法代码示例。如果您正苦于以下问题:Java Set.toArray方法的具体用法?Java Set.toArray怎么用?Java Set.toArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Set
的用法示例。
在下文中一共展示了Set.toArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toCallEventTypeArray
import java.util.Set; //导入方法依赖的package包/类
private Event.Type[] toCallEventTypeArray(final Set<Trigger> triggers) {
final Set<Event.Type> events = new LinkedHashSet<Event.Type>();
for (Trigger trigger : triggers) {
switch (trigger) {
case BEFORE:
events.add(Event.Type.CALL_BEFORE);
break;
case RETURN:
events.add(Event.Type.CALL_RETURN);
break;
case THROWS:
events.add(Event.Type.CALL_THROWS);
break;
}
}
return events.toArray(new Event.Type[]{});
}
示例2: testNodesSelectors
import java.util.Set; //导入方法依赖的package包/类
public void testNodesSelectors() {
TransportNodesAction action = getTestTransportNodesAction();
int numSelectors = randomIntBetween(1, 5);
Set<String> nodeSelectors = new HashSet<>();
for (int i = 0; i < numSelectors; i++) {
nodeSelectors.add(randomFrom(NodeSelector.values()).selector);
}
int numNodeIds = randomIntBetween(0, 3);
String[] nodeIds = clusterService.state().nodes().getNodes().keys().toArray(String.class);
for (int i = 0; i < numNodeIds; i++) {
String nodeId = randomFrom(nodeIds);
nodeSelectors.add(nodeId);
}
String[] finalNodesIds = nodeSelectors.toArray(new String[nodeSelectors.size()]);
TestNodesRequest request = new TestNodesRequest(finalNodesIds);
action.new AsyncAction(null, request, new PlainActionFuture<>()).start();
Map<String, List<CapturingTransport.CapturedRequest>> capturedRequests = transport.getCapturedRequestsByTargetNodeAndClear();
assertEquals(clusterService.state().nodes().resolveNodes(finalNodesIds).length, capturedRequests.size());
}
示例3: get
import java.util.Set; //导入方法依赖的package包/类
public File[] get(File key) {
LOG.log(Level.FINE, "get({0})", new Object[]{key});
if(key == null) {
return new File[0];
}
synchronized(this) {
Set<File> ret = index.get(key);
if(ret == null) {
LOG.log(Level.FINE, " get({0}) returns no files", new Object[]{key});
return new File[0];
}
LOG.log(Level.FINE, " get({0}) returns {1}", new Object[]{key, ret.size()});
if(LOG.isLoggable(Level.FINER)) {
LOG.finer(" " + ret);
}
return ret.toArray(new File[ret.size()]);
}
}
示例4: destroyFromTempQueue
import java.util.Set; //导入方法依赖的package包/类
private boolean destroyFromTempQueue(PartitionedRegion qPR, int bId, Object key) {
boolean isDestroyed = false;
Set queues = qPR.getParallelGatewaySender().getQueues();
if (queues != null) {
ConcurrentParallelGatewaySenderQueue prq =
(ConcurrentParallelGatewaySenderQueue) queues.toArray()[0];
BlockingQueue<GatewaySenderEventImpl> tempQueue = prq.getBucketTmpQueue(bId);
if (tempQueue != null) {
Iterator<GatewaySenderEventImpl> itr = tempQueue.iterator();
while (itr.hasNext()) {
GatewaySenderEventImpl eventForFilter = itr.next();
// fix for #48082
afterAckForSecondary_EventInTempQueue(qPR.getParallelGatewaySender(), eventForFilter);
if (eventForFilter.getShadowKey().equals(key)) {
itr.remove();
eventForFilter.release(); // GEODE-1282
isDestroyed = true;
}
}
}
}
return isDestroyed;
}
示例5: evaluate
import java.util.Set; //导入方法依赖的package包/类
@Override
public Object[] evaluate(Input[] args) {
DataType innerType = ((ArrayType)this.info().returnType()).innerType();
Set<Object> uniqueSet = new LinkedHashSet<>();
for(Input array : args){
if(array == null || array.value() == null){
continue;
}
Object[] arg = (Object[]) array.value();
for(Object element: arg){
uniqueSet.add(innerType.value(element));
}
}
return uniqueSet.toArray();
}
示例6: getImplementedInterfaces
import java.util.Set; //导入方法依赖的package包/类
/**
* Retrieves a list with all interfaces implemented by the given class. If possible gets this information from a cache instead of navigating through the
* object hierarchy. Results are stored in a cache for future reference.
*
* @param clazz
* The class from which the interface list will be retrieved.
* @return
* An array with all the interfaces for the given class.
*/
public static Class<?>[] getImplementedInterfaces(Class<?> clazz) {
Class<?>[] implementedInterfaces = Util.implementedInterfacesCache.get(clazz);
if (implementedInterfaces != null) {
return implementedInterfaces;
}
Set<Class<?>> interfaces = new LinkedHashSet<Class<?>>();
Class<?> superClass = clazz;
do {
Collections.addAll(interfaces, (Class<?>[]) superClass.getInterfaces());
} while ((superClass = superClass.getSuperclass()) != null);
implementedInterfaces = interfaces.toArray(new Class<?>[interfaces.size()]);
Class<?>[] oldValue = Util.implementedInterfacesCache.putIfAbsent(clazz, implementedInterfaces);
if (oldValue != null) {
implementedInterfaces = oldValue;
}
return implementedInterfaces;
}
示例7: listLocators
import java.util.Set; //导入方法依赖的package包/类
/**
*
* @return the list of all locators present in the system
*/
public String[] listLocators() {
if (cache != null) {
// each locator is a string of the form host[port] or bind-addr[port]
Set<String> set = new HashSet<String>();
Map<InternalDistributedMember, Collection<String>> map =
cache.getDistributionManager().getAllHostedLocators();
for (Collection<String> hostedLocators : map.values()) {
for (String locator : hostedLocators) {
set.add(locator);
}
}
String[] locators = set.toArray(new String[set.size()]);
return locators;
}
return ManagementConstants.NO_DATA_STRING;
}
示例8: getPropertyNames
import java.util.Set; //导入方法依赖的package包/类
@Override
public String[] getPropertyNames() {
Set<String> propertyNames = this.source.getPropertyNames();
if (propertyNames.isEmpty()) {
return EMPTY_ARRAY;
}
return propertyNames.toArray(new String[propertyNames.size()]);
}
示例9: checkPackage
import java.util.Set; //导入方法依赖的package包/类
/**
* 排重、检测package父子关系,避免多次扫描
*
* @param scanPackages
* @return 返回检查后有效的路径集合
*/
private static Set<String> checkPackage(String scanPackages) {
if (StringUtils.isBlank(scanPackages)) {
return Collections.emptySet();
}
Set<String> packages = new HashSet<String>();
// 排重路径
Collections.addAll(packages, scanPackages.split(","));
for (String pInArr : packages.toArray(new String[packages.size()])) {
if (StringUtils.isBlank(pInArr) || pInArr.equals(STRING_DIAN) || pInArr.startsWith(STRING_DIAN)) {
continue;
}
if (pInArr.endsWith(STRING_DIAN)) {
pInArr = pInArr.substring(0, pInArr.length() - 1);
}
Iterator<String> packageIte = packages.iterator();
boolean needAdd = true;
while (packageIte.hasNext()) {
String pack = packageIte.next();
if (pInArr.startsWith(pack + DIAN)) {
// 如果待加入的路径是已经加入的pack的子集,不加入
needAdd = false;
}
else if (pack.startsWith(pInArr + DIAN)) {
// 如果待加入的路径是已经加入的pack的父集,删除已加入的pack
packageIte.remove();
}
}
if (needAdd) {
packages.add(pInArr);
}
}
return packages;
}
示例10: init
import java.util.Set; //导入方法依赖的package包/类
private void init() {
createCommandTree();
// NOTE order is important here
loadCommands();
Set<String> keys = myCommands.keySet();
commandsComboBox = new JComboBox<String>(keys.toArray(new String[keys.size()]));
this.getContentPane().add(createCommandPanel(), BorderLayout.SOUTH);
this.pack();
}
示例11: getAllUsers
import java.util.Set; //导入方法依赖的package包/类
/**
* Get all users contained in this group
* @return ScriptUser[]
*/
public ScriptUser[] getAllUsers()
{
Set<String> children = authorityService.getContainedAuthorities(AuthorityType.USER, fullName, false);
Set<ScriptUser> users = new LinkedHashSet<ScriptUser>();
for (String authority : children)
{
ScriptUser user = new ScriptUser(authority, null, serviceRegistry, this.scope);
users.add(user);
}
return users.toArray(new ScriptUser[users.size()]);
}
示例12: toSortedPrefixFreeCharArrays
import java.util.Set; //导入方法依赖的package包/类
public static char[][] toSortedPrefixFreeCharArrays(final Set<String> set) {
final int size = set.size();
final String[] s = set.toArray(new String[size]);
Arrays.sort(s);
int j = 0;
if (size != 0) {
for(int i = 1; i < size; i++) if (! s[i].startsWith(s[j])) s[++j] = s[i];
++j;
}
final char[][] result = new char[j][];
for(int i = 0; i < j; i++) result[i] = s[i].toCharArray();
return result;
}
示例13: handleMapChange
import java.util.Set; //导入方法依赖的package包/类
@Override
public void handleMapChange ( final MapChangeEvent event )
{
final Set<?> affectedElements = event.diff.getChangedKeys ();
if ( !affectedElements.isEmpty () )
{
final LabelProviderChangedEvent newEvent = new LabelProviderChangedEvent ( ConfigurationCellLabelProvider.this, affectedElements.toArray () );
fireLabelProviderChanged ( newEvent );
}
}
示例14: checkPagesExistOffline
import java.util.Set; //导入方法依赖的package包/类
/**
* Returns via callback any urls in <code>urls</code> for which there exist offline pages.
*
* TODO(http://crbug.com/598006): Add metrics for preventing UI jank.
*/
public void checkPagesExistOffline(Set<String> urls, Callback<Set<String>> callback) {
String[] urlArray = urls.toArray(new String[urls.size()]);
CheckPagesExistOfflineCallbackInternal callbackInternal =
new CheckPagesExistOfflineCallbackInternal(callback);
nativeCheckPagesExistOffline(mNativeOfflinePageBridge, urlArray, callbackInternal);
}
示例15: testKeySetToArray
import java.util.Set; //导入方法依赖的package包/类
/**
* keySet.toArray returns contains all keys
*/
public void testKeySetToArray() {
ConcurrentNavigableMap map = map5();
Set s = map.keySet();
Object[] ar = s.toArray();
assertTrue(s.containsAll(Arrays.asList(ar)));
assertEquals(5, ar.length);
ar[0] = m10;
assertFalse(s.containsAll(Arrays.asList(ar)));
}