⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timeboundingbox.java

📁 fortran并行计算包
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            else                intersect_earliest_time = this.earliest_time;            if ( this.latest_time < endtimes.latest_time )                intersect_latest_time   = this.latest_time;            else                intersect_latest_time   = endtimes.latest_time;            intersect_duration  = intersect_latest_time                                - intersect_earliest_time;            if ( intersect_duration > 0.0d )                return intersect_duration;            else                return 0.0d;        }        else            return 0.0d;    }    /* For SLOG-2 Input API & viewer */    public double getDuration()    {        return latest_time - earliest_time;    }    public void setZeroDuration( double time )    {        earliest_time = time;        latest_time   = time;    }    public static void writeObject( final TimeBoundingBox  timebox,                                          DataOutput       outs )    throws java.io.IOException    {        outs.writeDouble( timebox.earliest_time );        outs.writeDouble( timebox.latest_time );        // timebox.writeObject( outs ) invokes InfoBox.writeObject( outs )    }    public static void readObject( TimeBoundingBox  timebox,                                   DataInput        ins )    throws java.io.IOException    {        timebox.earliest_time  = ins.readDouble();        timebox.latest_time    = ins.readDouble();    }      public void writeObject( DataOutput outs )    throws java.io.IOException    {        outs.writeDouble( earliest_time );        outs.writeDouble( latest_time );    }    public TimeBoundingBox( DataInput ins )    throws java.io.IOException    {        this.readObject( ins );    }    public void readObject( DataInput ins )    throws java.io.IOException    {        earliest_time  = ins.readDouble();        latest_time    = ins.readDouble();    }    public String toString()    {        /*        if ( latest_time - earliest_time >= 0 )            return ( "TimeBBox( + )" );        else            return ( "TimeBBox( - )" );        */        return ( "TimeBBox(" + earliest_time + "," + latest_time + ")" );    }    public String toShortString()    {        return ( "TimeBBox(" + (float) earliest_time                       + "," + (float) latest_time + ")" );    }    /*        Define TimeBoundingBox.Order as an alias of java.util.Comparator    */    public interface Order extends Comparator    {        public boolean isIncreasingTimeOrdered();        public boolean isStartTimeOrdered();        public String  toString();    }/*    This comparator to Collections.sort() will arrange TimeBoundingBoxs    in increasing starttime order.  If starttimes are equals, TimeBoundingBox    will then be arranged in decreasing finaltime order.*/    private static class IncreasingStarttimeOrder implements Order    {        public int compare( Object o1, Object o2 )        {            TimeBoundingBox  timebox1, timebox2;            timebox1 = (TimeBoundingBox) o1;            timebox2 = (TimeBoundingBox) o2;            if ( timebox1.earliest_time != timebox2.earliest_time )                // increasing starttime order ( 1st order )                return ( timebox1.earliest_time < timebox2.earliest_time                       ? -1 : 1 );            else {                if ( timebox1.latest_time != timebox2.latest_time )                    // decreasing finaltime order ( 2nd order )                    return ( timebox1.latest_time > timebox2.latest_time                           ? -1 : 1 );                else {                    // if ( timebox1 == timebox2 )                        return 0;                }   // FinalTime            }   // StartTime        }        public boolean isIncreasingTimeOrdered() {return true;}        public boolean isStartTimeOrdered() {return true;}        public String toString() {return "INCRE_STARTTIME_ORDER";}    }/*    This comparator to Collections.sort() will arrange TimeBoundingBoxs    in decreasing starttime order.  If starttimes are equals, TimeBoundingBox    will then be arranged in increasing finaltime order.*/    private static class DecreasingStarttimeOrder implements Order    {        public int compare( Object o1, Object o2 )        {            TimeBoundingBox  timebox1, timebox2;            timebox1 = (TimeBoundingBox) o1;            timebox2 = (TimeBoundingBox) o2;            if ( timebox1.earliest_time != timebox2.earliest_time )                // decreasing starttime order ( 1st order )                return ( timebox1.earliest_time > timebox2.earliest_time                       ? -1 : 1 );            else {                if ( timebox1.latest_time != timebox2.latest_time )                    // increasing finaltime order ( 2nd order )                    return ( timebox1.latest_time < timebox2.latest_time                           ? -1 : 1 );                else {                    // if ( timebox1 == timebox2 )                        return 0;                }   // FinalTime            }   // StartTime        }        public boolean isIncreasingTimeOrdered() {return false;}        public boolean isStartTimeOrdered() {return true;}        public String toString() {return "DECRE_STARTTIME_ORDER";}    }/*    This comparator to Collections.sort() will arrange TimeBoundingBoxs    in increasing finaltime order.  If finaltimes are equals, TimeBoundingBox    will then be arranged in decreasing starttime order.*/    private static class IncreasingFinaltimeOrder implements Order    {        public int compare( Object o1, Object o2 )        {            TimeBoundingBox  timebox1, timebox2;            timebox1 = (TimeBoundingBox) o1;            timebox2 = (TimeBoundingBox) o2;            if ( timebox1.latest_time != timebox2.latest_time )                // increasing finaltime order ( 1st order )                return ( timebox1.latest_time < timebox2.latest_time                       ? -1 : 1 );            else {                if ( timebox1.earliest_time != timebox2.earliest_time )                    // decreasing starttime order ( 2nd order )                    return ( timebox1.earliest_time > timebox2.earliest_time                           ? -1 : 1 );                else {                    // if ( timebox1 == timebox2 )                        return 0;                }   // StartTime            }   // FinalTime        }        public boolean isIncreasingTimeOrdered() {return true;}        public boolean isStartTimeOrdered() {return false;}        public String toString() {return "INCRE_FINALTIME_ORDER";}    }/*    This comparator to Collections.sort() will arrange TimeBoundingBoxs    in decreasing finaltime order.  If finaltimes are equals, TimeBoundingBox    will then be arranged in increasing starttime order.*/    private static class DecreasingFinaltimeOrder implements Order    {        public int compare( Object o1, Object o2 )        {            TimeBoundingBox  timebox1, timebox2;            timebox1 = (TimeBoundingBox) o1;            timebox2 = (TimeBoundingBox) o2;            if ( timebox1.latest_time != timebox2.latest_time )                // increasing finaltime order ( 1st order )                return ( timebox1.latest_time > timebox2.latest_time                       ? -1 : 1 );            else {                if ( timebox1.earliest_time != timebox2.earliest_time )                    // decreasing starttime order ( 2nd order )                    return ( timebox1.earliest_time < timebox2.earliest_time                           ? -1 : 1 );                else {                    // if ( timebox1 == timebox2 )                        return 0;                }   // StartTime            }   // FinalTime        }        public boolean isIncreasingTimeOrdered() {return false;}        public boolean isStartTimeOrdered() {return false;}        public String toString() {return "DECRE_FINALTIME_ORDER";}    }    public static final void main( String[] args )    {        TimeBoundingBox timebox = new TimeBoundingBox();        System.out.println( timebox );        if ( INCRE_STARTTIME_ORDER.equals( DECRE_STARTTIME_ORDER ) )            System.out.println( "INCRE_STARTTIME_ORDER=DECRE_STARTTIME_ORDER" );        else            System.out.println( "INCRE_STARTTIME_ORDER!DECRE_STARTTIME_ORDER" );        if ( INCRE_STARTTIME_ORDER.equals( INCRE_FINALTIME_ORDER ) )            System.out.println( "INCRE_STARTTIME_ORDER=INCRE_FINALTIME_ORDER" );        else            System.out.println( "INCRE_STARTTIME_ORDER!INCRE_FINALTIME_ORDER" );        if ( INCRE_STARTTIME_ORDER.equals( DECRE_FINALTIME_ORDER ) )            System.out.println( "INCRE_STARTTIME_ORDER=DECRE_FINALTIME_ORDER" );        else            System.out.println( "INCRE_STARTTIME_ORDER!DECRE_FINALTIME_ORDER" );        if ( INCRE_STARTTIME_ORDER.equals( INCRE_STARTTIME_ORDER ) )            System.out.println( "INCRE_STARTTIME_ORDER=INCRE_STARTTIME_ORDER" );        else            System.out.println( "INCRE_STARTTIME_ORDER!INCRE_STARTTIME_ORDER" );        TimeBoundingBox.Order tmp_order = new IncreasingStarttimeOrder();        if ( INCRE_STARTTIME_ORDER.equals( tmp_order ) )            System.out.println( "INCRE_STARTTIME_ORDER=tmp_order" );        else            System.out.println( "INCRE_STARTTIME_ORDER!tmp_order" );    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -