Class TSynchronizedFloatCollections



  • public class TSynchronizedFloatCollections
    extends Object
    • Method Detail

      • wrap

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

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

          TFloatCollection c = TSynchronizedFloatCollections.wrap( myCollection );
             ...
          synchronized( c ) {
              TFloatIterator i = c.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 collection does not pass the hashCode and equals operations through to the backing collection, but relies on Object's equals and hashCode methods. This is necessary to preserve the contracts of these operations in the case that the backing collection is a set or a list.

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

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