Class TSynchronizedFloatSets



  • public class TSynchronizedFloatSets
    extends Object
    • Method Detail

      • wrap

        public static TFloatSet wrap(TFloatSet s)
        Returns a synchronized (thread-safe) Trove set backed by the specified set. In order to guarantee serial access, it is critical that all access to the backing set is accomplished through the returned set.

        It is imperative that the user manually synchronize on the returned set when iterating over it:

          TFloatSet s = TSynchronizedFloatSets.wrap( new TFloatHashSet() );
              ...
          synchronized(s) {
              TFloatIterator i = s.iterator(); // Must be in the synchronized block
              while ( i.hasNext() )
                  foo( i.next() );
          }
         
        Failure to follow this advice may result in non-deterministic behavior.

        The returned set will be serializable if the specified set is serializable.

        Parameters:
        s - the set to be "wrapped" in a synchronized set.
        Returns:
        a synchronized view of the specified set.