當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。