当前位置: 首页>>代码示例>>Java>>正文


Java TreeSet.toArray方法代码示例

本文整理汇总了Java中java.util.TreeSet.toArray方法的典型用法代码示例。如果您正苦于以下问题:Java TreeSet.toArray方法的具体用法?Java TreeSet.toArray怎么用?Java TreeSet.toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.TreeSet的用法示例。


在下文中一共展示了TreeSet.toArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convertToFlip

import java.util.TreeSet; //导入方法依赖的package包/类
/**
 * Converts the nice Java representation of a kdb table into the actual format ready for sending across
 * the wire to a kdb process. <b>NOTE</b>: The columns of the generated table will <i>always</i> be in 
 * alphabetical order.
 * @return The object that can be sent to a kdb process
 */
public Flip convertToFlip() {
	if(isEmpty())
		return null;

	// Used TreeSet to enforce alphabetical (and deterministic) ordering of column names 
	TreeSet<String> orderedCols = new TreeSet<>(data.keySet());
	
	String[] colNames = orderedCols.toArray(new String[0]);
	Object[] cols = new Object[data.keySet().size()];
	
	log.trace("Generating kdb Flip object [ Table: {} ] [ Row Count: {} ] [ Columns: {} ]", tableName, rowCount, orderedCols);
	
	for(int kCount = 0; kCount < colNames.length; kCount++)
		cols[kCount] = data.get(colNames[kCount]).toArray();
	
	return new Flip(new Dict(colNames, cols));
}
 
开发者ID:BuaBook,项目名称:java-kdb-communication,代码行数:24,代码来源:KdbTable.java

示例2: overwriteUserDictionaryPreference

import java.util.TreeSet; //导入方法依赖的package包/类
private void overwriteUserDictionaryPreference(final Preference userDictionaryPreference) {
    final Activity activity = getActivity();
    final TreeSet<String> localeList = UserDictionaryList.getUserDictionaryLocalesSet(activity);
    if (null == localeList) {
        // The locale list is null if and only if the user dictionary service is
        // not present or disabled. In this case we need to remove the preference.
        getPreferenceScreen().removePreference(userDictionaryPreference);
    } else if (localeList.size() <= 1) {
        userDictionaryPreference.setFragment(UserDictionarySettings.class.getName());
        // If the size of localeList is 0, we don't set the locale parameter in the
        // extras. This will be interpreted by the UserDictionarySettings class as
        // meaning "the current locale".
        // Note that with the current code for UserDictionaryList#getUserDictionaryLocalesSet()
        // the locale list always has at least one element, since it always includes the current
        // locale explicitly. @see UserDictionaryList.getUserDictionaryLocalesSet().
        if (localeList.size() == 1) {
            final String locale = (String)localeList.toArray()[0];
            userDictionaryPreference.getExtras().putString("locale", locale);
        }
    } else {
        userDictionaryPreference.setFragment(UserDictionaryList.class.getName());
    }
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:24,代码来源:CorrectionSettingsFragment.java

示例3: computeVlandIds

import java.util.TreeSet; //导入方法依赖的package包/类
private VlanVid[] computeVlandIds() {
    if (entities.length == 1) {
        if (entities[0].getVlan() != null) {
            return new VlanVid[]{ entities[0].getVlan() };
        } else {
            return new VlanVid[] { VlanVid.ofVlan(-1) };
        }
    }

    TreeSet<VlanVid> vals = new TreeSet<VlanVid>();
    for (Entity e : entities) {
        if (e.getVlan() == null)
            vals.add(VlanVid.ofVlan(-1));
        else
            vals.add(e.getVlan());
    }
    return vals.toArray(new VlanVid[vals.size()]);
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:19,代码来源:Device.java

示例4: getViewDependency

import java.util.TreeSet; //导入方法依赖的package包/类
public static String[] getViewDependency(String hiveQl) {
  if (hiveQl == null)
    return new String[]{};

  try {
    lineageInfoTool.getLineageInfo(hiveQl);
    TreeSet<String> inputs = lineageInfoTool.getInputTableList();
    return inputs.toArray(new String[inputs.size()]);
  } catch (Exception e) {
    logger.error("Sql statements : \n" + hiveQl + "\n parse ERROR, will return an empty String array");
    logger.error(String.valueOf(e.getCause()));
    return new String[]{};
  }
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:15,代码来源:HiveViewDependency.java

示例5: updateAnnotationSetsList

import java.util.TreeSet; //导入方法依赖的package包/类
protected void updateAnnotationSetsList() {
  String corpusName =
          (corpusToSearchIn.getSelectedItem()
                  .equals(Constants.ENTIRE_DATASTORE))
                  ? null
                  : (String)corpusIds
                          .get(corpusToSearchIn.getSelectedIndex() - 1);
  TreeSet<String> ts = new TreeSet<String>(stringCollator);
  ts.addAll(getAnnotationSetNames(corpusName));
  DefaultComboBoxModel<String> dcbm = new DefaultComboBoxModel<String>(ts.toArray(new String[ts.size()]));
  dcbm.insertElementAt(Constants.ALL_SETS, 0);
  annotationSetsToSearchIn.setModel(dcbm);
  annotationSetsToSearchIn.setSelectedItem(Constants.ALL_SETS);

  // used in the ConfigureStackViewFrame as Annotation type column
  // cell editor
  TreeSet<String> types = new TreeSet<String>(stringCollator);
  types.addAll(getTypesAndFeatures(null, null).keySet());
  // put all annotation types from the datastore
  // combobox used as cell editor
  JComboBox<String> annotTypesBox = new JComboBox<String>();
  annotTypesBox.setMaximumRowCount(10);
  annotTypesBox.setModel(new DefaultComboBoxModel<String>(types.toArray(new String[types.size()])));
  DefaultCellEditor cellEditor = new DefaultCellEditor(annotTypesBox);
  cellEditor.setClickCountToStart(0);
  configureStackViewFrame.getTable().getColumnModel()
          .getColumn(ANNOTATION_TYPE).setCellEditor(cellEditor);
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:29,代码来源:LuceneDataStoreSearchGUI.java

示例6: getWindowsPortNames

import java.util.TreeSet; //导入方法依赖的package包/类
private static String[] getWindowsPortNames(Pattern pattern, Comparator<String> comparator) {
    String[] portNames = serialInterface.getSerialPortNames();
    if (portNames == null) {
        return new String[0];
    }
    TreeSet<String> ports = new TreeSet<>(comparator);
    for (String portName : portNames) {
        if (pattern.matcher(portName).find()) {
            ports.add(portName);
        }
    }
    return ports.toArray(new String[ports.size()]);
}
 
开发者ID:trol73,项目名称:avr-bootloader,代码行数:14,代码来源:SerialPortList.java

示例7: getUnixBasedPortNames

import java.util.TreeSet; //导入方法依赖的package包/类
private static String[] getUnixBasedPortNames(String searchPath, Pattern pattern, Comparator<String> comparator) {
    searchPath = searchPath + "/";
    String[] returnArray = new String[0];
    File dir = new File(searchPath);
    if (dir.exists() && dir.isDirectory()) {
        File[] files = dir.listFiles();
        if (files != null && files.length > 0) {
            TreeSet<String> portsTree = new TreeSet<>(comparator);
            for (File file : files) {
                String fileName = file.getName();
                if (!file.isDirectory() && !file.isFile() && pattern.matcher(fileName).find()) {
                    String portName = searchPath + fileName;

                    if (fileName.startsWith("ttyS")) {
                        long portHandle = serialInterface.openPort(portName, false);
                        if (portHandle < 0L && portHandle != -1L) {
                            continue;
                        }
                        if (portHandle != -1L) {
                            serialInterface.closePort(portHandle);
                        }
                    }
                    portsTree.add(portName);
                }
            }
            returnArray = portsTree.toArray(returnArray);
        }
    }
    return returnArray;
}
 
开发者ID:trol73,项目名称:avr-bootloader,代码行数:31,代码来源:SerialPortList.java

示例8: run

import java.util.TreeSet; //导入方法依赖的package包/类
public void run(){
    TreeSet<Variable> variables = new TreeSet<Variable>();
    constraints.collectVariables(variables);
    int varCount = variables.size();
    Variable[] varArray = variables.toArray(new Variable[varCount]);
    Constant[][] values = new Constant[varCount][];
    for (int i = 0; i < varCount; i++){
	values[i] = getPossibleValues(varArray[i].getType());
    }
    int[] currentSolutionIDX = new int[varCount];
    while (run && currentSolutionIDX[varCount - 1] < values[varCount - 1].length){
	Solution testSolution = new Solution();
	for (int i = 0; i < varCount; i++)
	    testSolution.addBinding(varArray[i], values[i][currentSolutionIDX[i]]);
	try{
	    if (constraints.validateSolution(testSolution)){
		DefaultValueGuessSolver.this.solution = testSolution;
		run = false;
		break;
	    }
	} catch (IncompleteSolutionException ise){
	    throw new InternalError(ise.toString());
	}
	currentSolutionIDX[0]++;
	for (int idx = 0; currentSolutionIDX[idx] == values[idx].length && idx < currentSolutionIDX.length - 1; idx++){
	    currentSolutionIDX[idx] = 0;
	    currentSolutionIDX[idx+1]++;
	}
    }
}
 
开发者ID:wwu-pi,项目名称:tap17-muggl-javaee,代码行数:31,代码来源:DefaultValueGuessSolver.java

示例9: testToArray

import java.util.TreeSet; //导入方法依赖的package包/类
/**
 * toArray contains all elements in sorted order
 */
public void testToArray() {
    TreeSet q = populatedSet(SIZE);
    Object[] o = q.toArray();
    for (int i = 0; i < o.length; i++)
        assertSame(o[i], q.pollFirst());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:TreeSetTest.java

示例10: testToArray2

import java.util.TreeSet; //导入方法依赖的package包/类
/**
 * toArray(a) contains all elements in sorted order
 */
public void testToArray2() {
    TreeSet<Integer> q = populatedSet(SIZE);
    Integer[] ints = new Integer[SIZE];
    Integer[] array = q.toArray(ints);
    assertSame(ints, array);
    for (int i = 0; i < ints.length; i++)
        assertSame(ints[i], q.pollFirst());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:TreeSetTest.java

示例11: computeVlandIds

import java.util.TreeSet; //导入方法依赖的package包/类
private VlanVid[] computeVlandIds() {
	if (entities.length == 1) {
		return new VlanVid[] { entities[0].getVlan() };
	}

	TreeSet<VlanVid> vals = new TreeSet<VlanVid>();
	for (Entity e : entities) {
		vals.add(e.getVlan());
	}
	return vals.toArray(new VlanVid[vals.size()]);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:12,代码来源:Device.java

示例12: getIPv4Addresses

import java.util.TreeSet; //导入方法依赖的package包/类
@Override
public IPv4Address[] getIPv4Addresses() {
	// XXX - TODO we can cache this result. Let's find out if this
	// is really a performance bottleneck first though.

	TreeSet<IPv4Address> vals = new TreeSet<IPv4Address>();
	for (Entity e : entities) {
		if (e.getIpv4Address().equals(IPv4Address.NONE))
			continue;

		// We have an IP address only if among the devices within the class
		// we have the most recent entity with that IP.
		boolean validIP = true;
		Iterator<Device> devices = deviceManager.queryClassByEntity(
				entityClass, ipv4Fields, e);
		while (devices.hasNext()) {
			Device d = devices.next();
			if (deviceKey.equals(d.getDeviceKey()))
				continue;
			for (Entity se : d.entities) {
				if (se.getIpv4Address() != null
						&& se.getIpv4Address().equals(e.getIpv4Address())
						&& !se.getLastSeenTimestamp()
								.equals(Entity.NO_DATE)
						&& 0 < se.getLastSeenTimestamp().compareTo(
								e.getLastSeenTimestamp())) {
					validIP = false;
					break;
				}
			}
			if (!validIP)
				break;
		}

		if (validIP)
			vals.add(e.getIpv4Address());
	}

	return vals.toArray(new IPv4Address[vals.size()]);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:41,代码来源:Device.java

示例13: getIPv6Addresses

import java.util.TreeSet; //导入方法依赖的package包/类
@Override
public IPv6Address[] getIPv6Addresses() {
	TreeSet<IPv6Address> vals = new TreeSet<IPv6Address>();
	for (Entity e : entities) {
		if (e.getIpv6Address().equals(IPv6Address.NONE))
			continue;

		// We have an IP address only if among the devices within the class
		// we have the most recent entity with that IP.
		boolean validIP = true;
		Iterator<Device> devices = deviceManager.queryClassByEntity(
				entityClass, ipv6Fields, e);
		while (devices.hasNext()) {
			Device d = devices.next();
			if (deviceKey.equals(d.getDeviceKey()))
				continue;
			for (Entity se : d.entities) {
				if (se.getIpv6Address() != null
						&& se.getIpv6Address().equals(e.getIpv6Address())
						&& !se.getLastSeenTimestamp()
								.equals(Entity.NO_DATE)
						&& 0 < se.getLastSeenTimestamp().compareTo(
								e.getLastSeenTimestamp())) {
					validIP = false;
					break;
				}
			}
			if (!validIP)
				break;
		}

		if (validIP)
			vals.add(e.getIpv6Address());
	}

	return vals.toArray(new IPv6Address[vals.size()]);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:38,代码来源:Device.java

示例14: getRsCoprocessors

import java.util.TreeSet; //导入方法依赖的package包/类
/**
 * Return the RegionServer-level and Region-level coprocessors
 * @return string array of loaded RegionServer-level and
 *         Region-level coprocessors
 */
public String[] getRsCoprocessors() {
  // Need a set to remove duplicates, but since generated Coprocessor class
  // is not Comparable, make it a Set<String> instead of Set<Coprocessor>
  TreeSet<String> coprocessSet = new TreeSet<String>();
  for (Coprocessor coprocessor : obtainServerLoadPB().getCoprocessorsList()) {
    coprocessSet.add(coprocessor.getName());
  }
  return coprocessSet.toArray(new String[coprocessSet.size()]);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:15,代码来源:ServerLoad.java

示例15: getIPv6Addresses

import java.util.TreeSet; //导入方法依赖的package包/类
@Override
public IPv6Address[] getIPv6Addresses() {
    TreeSet<IPv6Address> vals = new TreeSet<IPv6Address>();
    for (Entity e : entities) {
        if (e.getIpv6Address().equals(IPv6Address.NONE)) continue;
        vals.add(e.getIpv6Address());
    }
    
    return vals.toArray(new IPv6Address[vals.size()]);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:11,代码来源:MockDevice.java


注:本文中的java.util.TreeSet.toArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。