Package ucar.nc2.iosp

Interface Layout

  • All Known Subinterfaces:
    LayoutBB
    All Known Implementing Classes:
    LayoutBBTiled, LayoutRegular, LayoutRegularSegmented, LayoutSegmented, LayoutTiled

    public interface Layout
    Iterator to read/write subsets of a multidimensional array, finding the contiguous chunks. The iteration is monotonic in both src and dest positions.

    Example for Integers:

      int[] read( Layout index, int[] src) {
        int[] dest = new int[index.getTotalNelems()];
        while (index.hasNext()) {
          Layout.Chunk chunk = index.next();
          System.arraycopy(src, chunk.getSrcElem(), dest, chunk.getDestElem(), chunk.getNelems());
        }
        return dest;
      }
    
      int[] read( Layout index, RandomAccessFile raf) {
        int[] dest = new int[index.getTotalNelems()];
        while (index.hasNext()) {
          Layout.Chunk chunk = index.next();
          raf.seek( chunk.getSrcPos());
          raf.readInt(dest, chunk.getDestElem(), chunk.getNelems());
        }
        return dest;
      }
    
       // note src and dest misnamed
        void write( Layout index, int[] src, RandomAccessFile raf) {
          while (index.hasNext()) {
            Layout.Chunk chunk = index.next();
            raf.seek ( chunk.getSrcPos());
            for (int k=0; k<chunk.getNelems(); k++)
              raf.writeInt(src, chunk.getDestElem(), chunk.getNelems());
              raf.writeInt( ii.getByteNext());
          }
     
     
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static interface  Layout.Chunk
      A chunk of data that is contiguous in both the source and destination.
    • Method Detail

      • getTotalNelems

        long getTotalNelems()
        Get total number of elements in the wanted subset.
      • getElemSize

        int getElemSize()
        Get size of each element in bytes.
      • hasNext

        boolean hasNext()
        Is there more to do?
      • next

        Layout.Chunk next()
        Get the next chunk, not null if hasNext() is true.