On Aug 12, 2009, at 10:23 AM, Igor Peshansky wrote:

> But you could provide your own implementation of Marshal[Double]
> that reads bytes in whatever order you wish.  For example:
>
> class LSB {
>    public static class MyDoubleMarshal implements Marshal[Double] {
>        public def read(r: Reader): Double throws IOException {
>            var l: Long = 0l;
>            for (var shift: Int = 0; shift < 64; shift+=8) {
>                val b : Long = r.read();
>                l |= (b & 0xff) << shift;
>            }
>            return Double.fromLongBits(l);
>        }
>
>        public def write(w: Writer, d: Double): Void throws  
> IOException {
>            val l: Long = d.toLongBits();
>            for (var shift: Int = 0; shift < 64; shift+=8) {
>                val b = ((l >>> shift) & 0xffL) as Byte;
>                w.write(b);
>            }
>        }
>    }
>    const DOUBLE = new MyDoubleMarshal();
> }
>
> You can then use the above as follows:
>
>    val r: Reader = ...;
>    val d: Double = r.read(LSB.DOUBLE);
>
> or even
>
>    val da = Rail.makeVar[Double](100);
>    r.read(LSB.DOUBLE, da);
>
> to read an array of 100 doubles in LSB format.


This array is really a Rail (local). Given no apparent method for  
reading an Array[Double], can I read multiple Rail[Double] multiple  
time and assign each to a row in the Array[Double]? Otherwise it  
appears I would have to read each byte individually.

Jim 
  

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
X10-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to