本文整理汇总了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));
}
示例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());
}
}
示例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()]);
}
示例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[]{};
}
}
示例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);
}
示例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()]);
}
示例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;
}
示例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]++;
}
}
}
示例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());
}
示例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());
}
示例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()]);
}
示例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()]);
}
示例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()]);
}
示例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()]);
}
示例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()]);
}