Java Code Examples for java.util.Collections#synchronizedSortedSet()

The following examples show how to use java.util.Collections#synchronizedSortedSet() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OldCollectionsTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * java.util.Collections#synchronizedSortedSet(java.util.SortedSet)
 */
public void test_synchronizedSortedSetLjava_util_SortedSet() {
    try {
        // Regression for HARMONY-93
        Collections.synchronizedSortedSet(null);
        fail("Assert 0: synchronizedSortedSet(null) must throw NPE");
    } catch (NullPointerException e) {
        // expected
    }
}
 
Example 2
Source File: Network.java    From Qora with MIT License 5 votes vote down vote up
private void start()
{
	this.handledMessages = Collections.synchronizedSortedSet(new TreeSet<String>());
	
	//START ConnectionCreator THREAD
	creator = new ConnectionCreator(this);
	creator.start();
	
	//START ConnectionAcceptor THREAD
	acceptor = new ConnectionAcceptor(this);
	acceptor.start();
}
 
Example 3
Source File: QoSRtpFlow.java    From mts with GNU General Public License v3.0 5 votes vote down vote up
public QoSRtpFlow(CodecDictionary dico) {
       this.dico = dico;
	missingSequenceNumber = Collections.synchronizedSortedSet(new TreeSet<Integer>());//use this encapsulation to automatically synchronized the treeset access
	receivedSequenceNumber = Collections.synchronizedSortedSet(new TreeSet<Integer>());
	unexpectedPackets = Collections.synchronizedSortedSet(new TreeSet<Integer>());
       deltaList = new LinkedList<Float>();
       packetSpacingList = new LinkedList<Float>();
       jitterList = new LinkedList<Float>();
       eModele = new EModele();
}
 
Example 4
Source File: AbstractGempakStationFileReader.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Get the list of dates
 *
 * @param unique true for unique list
 * @return the list of dates
 */
protected List<String> makeDateList(boolean unique) {
  Key date = dateTimeKeys.get(0);
  Key time = dateTimeKeys.get(1);
  List<int[]> toCheck;
  if (date.type.equals(ROW)) {
    toCheck = headers.rowHeaders;
  } else {
    toCheck = headers.colHeaders;
  }
  List<String> fileDates = new ArrayList<>();
  for (int[] header : toCheck) {
    if (header[0] != IMISSD) {
      // convert to GEMPAK date/time
      int idate = header[date.loc + 1];
      int itime = header[time.loc + 1];
      // TODO: Add in the century
      String dateTime = GempakUtil.TI_CDTM(idate, itime);
      fileDates.add(dateTime);
    }
  }
  if (unique && !fileDates.isEmpty()) {
    SortedSet<String> uniqueTimes = Collections.synchronizedSortedSet(new TreeSet<>());
    uniqueTimes.addAll(fileDates);
    fileDates.clear();
    fileDates.addAll(uniqueTimes);
  }

  return fileDates;
}
 
Example 5
Source File: java_util_Collections_SynchronizedSortedSet.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
protected SortedSet<String> getAnotherObject() {
    SortedSet<String> set = new TreeSet<String>();
    return Collections.synchronizedSortedSet(set);
}
 
Example 6
Source File: java_util_Collections_SynchronizedSortedSet.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
protected SortedSet<String> getObject() {
    SortedSet<String> set = new TreeSet<String>();
    set.add("string");
    return Collections.synchronizedSortedSet(set);
}
 
Example 7
Source File: ReferenceTracker.java    From textuml with Eclipse Public License 1.0 4 votes vote down vote up
public Stage(Step sequence) {
    this.sequence = sequence;
    this.references = sequence.isOrdered() ? Collections
            .synchronizedSortedSet(new TreeSet<IDeferredReference>()) : Collections
            .synchronizedList(new LinkedList<IDeferredReference>());
}
 
Example 8
Source File: java_util_Collections_SynchronizedSortedSet.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
protected SortedSet<String> getObject() {
    SortedSet<String> set = new TreeSet<String>();
    set.add("string");
    return Collections.synchronizedSortedSet(set);
}
 
Example 9
Source File: java_util_Collections_SynchronizedSortedSet.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
protected SortedSet<String> getObject() {
    SortedSet<String> set = new TreeSet<String>();
    set.add("string");
    return Collections.synchronizedSortedSet(set);
}
 
Example 10
Source File: java_util_Collections_SynchronizedSortedSet.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
protected SortedSet<String> getAnotherObject() {
    SortedSet<String> set = new TreeSet<String>();
    return Collections.synchronizedSortedSet(set);
}
 
Example 11
Source File: AbstractRuntimeObjectSchemaTest.java    From protostuff with Apache License 2.0 4 votes vote down vote up
PojoWithObjectCollectionFields fill()
{
    LinkedList<String> ll = new LinkedList<String>();
    ll.add("zero");
    HashMap<String, Boolean> empty = newMap();

    TreeSet<String> ts = new TreeSet<String>();
    ts.add("two");

    EnumSet<Size> es = EnumSet.allOf(Size.class);

    emptySet = Collections.emptySet();
    emptyList = Collections.emptyList();
    singletonSet = Collections.singleton("three");
    singletonList = Collections.singletonList("four");
    setFromMap = Collections.newSetFromMap(empty);
    copiesList = Collections.nCopies(1, "five");

    unmodifiableCollection = Collections
            .unmodifiableCollection(Collections.emptyList()); // no
    // equals
    // impl
    unmodifiableSet = Collections.unmodifiableSet(Collections
            .emptySet());
    unmodifiableSortedSet = Collections.unmodifiableSortedSet(ts);
    unmodifiableList = Collections.unmodifiableList(ll);
    unmodifiableRandomAccessList = Collections
            .unmodifiableList(newList("six"));

    assertTrue(unmodifiableRandomAccessList.getClass().getName()
            .endsWith("RandomAccessList"));

    synchronizedCollection = Collections
            .synchronizedCollection(Collections.emptyList()); // no
    // equals
    // impl
    synchronizedSet = Collections.synchronizedSet(es);
    synchronizedSortedSet = Collections.synchronizedSortedSet(ts);
    synchronizedList = Collections.synchronizedList(ll);
    synchronizedRandomAccessList = Collections
            .synchronizedList(newList("seven"));

    assertTrue(synchronizedRandomAccessList.getClass().getName()
            .endsWith("RandomAccessList"));

    checkedCollection = Collections.checkedCollection(newList("eight"),
            String.class); // no equals impl
    checkedSet = Collections.checkedSet(es, Size.class);
    checkedSortedSet = Collections.checkedSortedSet(ts, String.class);
    checkedList = Collections.checkedList(ll, String.class);
    checkedRandomAccessList = Collections.checkedList(newList("nine"),
            String.class);

    assertTrue(checkedRandomAccessList.getClass().getName()
            .endsWith("RandomAccessList"));

    return this;
}
 
Example 12
Source File: ReferenceEvaluator.java    From abra2 with MIT License 4 votes vote down vote up
public void run() throws IOException, InterruptedException {
	new NativeLibraryLoader().load(".", NativeLibraryLoader.ABRA, false);
	CompareToReference2 c2r = new CompareToReference2();
	c2r.init8bit(reference);
	
	include = new BufferedWriter(new FileWriter(in, false));
	exclude = new BufferedWriter(new FileWriter(out, false));
	
	for (String chr : c2r.getChromosomes()) {
		includeRegions = Collections.synchronizedSortedSet(new TreeSet<Feature>(new RegionComparator()));
		excludeRegions = Collections.synchronizedSortedSet(new TreeSet<Feature>(new RegionComparator()));
		int i = 0;
		int chromosomeLength = c2r.getReferenceLength(chr);
		while (i < chromosomeLength - ReAligner.MAX_REGION_LENGTH) {
			int regionStart = i;
			int regionStop = i + ReAligner.MAX_REGION_LENGTH;
			int start = Math.max(regionStart - readLength, 0);
			int stop = Math.min(regionStop + readLength, chromosomeLength-1); 
			String regionBases = c2r.getSequence(chr, start+1, stop-start);
			Feature region = new Feature(chr, regionStart, regionStop);
			
			//TODO: Handle other ambiguous bases
			if (!regionBases.contains("N")) {
				threadManager.spawnThread(new EvalRunnable(threadManager, this, region, regionBases));
			} else {
				
				excludeRegions.add(region);
			}
			
			i += ReAligner.REGION_OVERLAP;
		}
		
		threadManager.waitForAllThreadsToComplete();
		
		//TODO: Because assembly regions are overlapped, there is overlap between final include/exclude output
		outputRegions(include, includeRegions);
		outputRegions(exclude, excludeRegions);
	}
	
	include.close();
	exclude.close();
	
	System.err.println("Done.");
}
 
Example 13
Source File: java_util_Collections_SynchronizedSortedSet.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
protected SortedSet<String> getObject() {
    SortedSet<String> set = new TreeSet<String>();
    set.add("string");
    return Collections.synchronizedSortedSet(set);
}
 
Example 14
Source File: DatawaveFieldIndexCachingIteratorJexl.java    From datawave with Apache License 2.0 4 votes vote down vote up
/**
 * This will setup the set for the specified range. This will attempt to reuse precomputed and persisted sets if we are allowed to.
 * 
 * @param row
 * @throws IOException
 */
protected void setupRowBasedHdfsBackedSet(String row) throws IOException {
    // we are done if cancelled
    if (this.setControl.isCancelledQuery()) {
        return;
    }
    
    try {
        // for each of the ivarator cache dirs
        for (IvaratorCacheDir ivaratorCacheDir : ivaratorCacheDirs) {
            // get the row specific dir
            Path rowDir = getRowDir(new Path(ivaratorCacheDir.getPathURI()), row);
            
            FileSystem fs = ivaratorCacheDir.getFs();
            
            // if we are not allowing reuse of directories, then delete it
            if (!allowDirReuse && fs.exists(rowDir)) {
                fs.delete(rowDir, true);
            }
        }
        
        // ensure the control directory is created
        Path controlRowDir = getRowDir(this.controlDir, row);
        if (!this.controlFs.exists(controlRowDir)) {
            this.controlFs.mkdirs(controlRowDir);
            this.createdRowDir = true;
        } else {
            this.createdRowDir = false;
        }
        
        this.set = new HdfsBackedSortedSet<>(null, hdfsBackedSetBufferSize, ivaratorCacheDirs, row, maxOpenFiles, numRetries, persistOptions,
                        new FileKeySortedSet.Factory());
        this.threadSafeSet = Collections.synchronizedSortedSet(this.set);
        this.currentRow = row;
        this.setControl.takeOwnership(row, this);
        
        // if this set is not marked as complete (meaning completely filled AND persisted), then we cannot trust the contents and we need to recompute.
        if (!this.setControl.isCompleteAndPersisted(row)) {
            this.set.clear();
            this.keys = null;
        } else {
            this.keys = new CachingIterator<>(this.set.iterator());
        }
        
        // reset the keyValues counter as we have a new set here
        scannedKeys.set(0);
    } catch (IOException ioe) {
        throw new IllegalStateException("Unable to create Hdfs backed sorted set", ioe);
    }
}
 
Example 15
Source File: BackupManagerImpl.java    From ralasafe with MIT License 4 votes vote down vote up
public Collection getBackups() {
	Collection backups = selector.select(new SelectCondition(), null);
	SortedSet result = Collections.synchronizedSortedSet(new TreeSet(comp));
	result.addAll(backups);
	return result;
}
 
Example 16
Source File: java_util_Collections_SynchronizedSortedSet.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
protected SortedSet<String> getAnotherObject() {
    SortedSet<String> set = new TreeSet<String>();
    return Collections.synchronizedSortedSet(set);
}
 
Example 17
Source File: java_util_Collections_SynchronizedSortedSet.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
protected SortedSet<String> getAnotherObject() {
    SortedSet<String> set = new TreeSet<String>();
    return Collections.synchronizedSortedSet(set);
}
 
Example 18
Source File: java_util_Collections_SynchronizedSortedSet.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
protected SortedSet<String> getObject() {
    SortedSet<String> set = new TreeSet<String>();
    set.add("string");
    return Collections.synchronizedSortedSet(set);
}
 
Example 19
Source File: SynchronizedCollectionsSerializer.java    From Iron with Apache License 2.0 4 votes vote down vote up
@Override
public Object create(final Object sourceCollection) {
    return Collections.synchronizedSortedSet((SortedSet<?>) sourceCollection);
}
 
Example 20
Source File: KwikiPDFToolBar.java    From ET_Redux with Apache License 2.0 4 votes vote down vote up
/**
 *
 * @param clearFiltering the value of clearFiltering
 */
public void performFilteringPerSliders(boolean clearFiltering) {

    Vector<ETFractionInterface> filteredFractions;
    if (clearFiltering) {
        filteredFractions = sample.getUpbFractionsUnknown();
    } else {
        filteredFractions = SampleDateInterpretationsUtilities.filterActiveUPbFractions(//
                sample.getUpbFractionsUnknown(),//
                ((DateProbabilityDensityPanel) probabilityPanel).getChosenDateName(),//
                positivePctDiscordance_slider.getValue(), //
                negativePctDiscordance_slider.getValue(), //
                percentUncertainty_slider.getValue());
    }

    // oct 2016 collect filtered fractions (those that still count) so that report table can show filtered out
    SortedSet<String> filteredFractionIDs = Collections.synchronizedSortedSet(new TreeSet<>());
    for (int i = 0; i < filteredFractions.size(); i++) {
        filteredFractionIDs.add(filteredFractions.get(i).getFractionID());
    }
    //need to also include reference material as all filtered in for report table
    Vector<ETFractionInterface> filteredRefMats = sample.getUpbFractionsReferenceMaterial();
    for (int i = 0; i < filteredRefMats.size(); i++) {
        filteredFractionIDs.add(filteredRefMats.get(i).getFractionID());
    }

    sample.setFilteredFractionIDs(filteredFractionIDs);

    ((AliquotDetailsDisplayInterface) concordiaGraphPanel).//
            setFilteredFractions(filteredFractions);

    ((DateProbabilityDensityPanel) probabilityPanel).//
            setSelectedFractions(filteredFractions);

    try {
        dateTreeByAliquot.performLastUserSelectionOfSampleDate();
    } catch (Exception selectionError) {
    }

    ((DateProbabilityDensityPanel) probabilityPanel).prepareAndPaintPanel();
    concordiaGraphPanel.repaint();
}