001 package cnslab.cnsnetwork; 002 003 /*********************************************************************** 004 * Neuron fire event, it contains the neuron fire time and neuron index. 005 * 006 * @version 007 * $Date: 2012-08-04 13:43:22 -0500 (Sat, 04 Aug 2012) $ 008 * $Rev: 104 $ 009 * $Author: croft $ 010 * @author 011 * Yi Dong 012 * @author 013 * David Wallace Croft 014 ***********************************************************************/ 015 public class FireEvent 016 implements Comparable<FireEvent>, Cloneable 017 //////////////////////////////////////////////////////////////////////// 018 //////////////////////////////////////////////////////////////////////// 019 { 020 021 /** neuron index */ 022 public int index; 023 024 /** time of neuron fire */ 025 public double time; 026 027 //////////////////////////////////////////////////////////////////////// 028 // constructor methods 029 //////////////////////////////////////////////////////////////////////// 030 031 public FireEvent ( 032 final int index, 033 final double time ) 034 //////////////////////////////////////////////////////////////////////// 035 { 036 this.index = index; 037 038 this.time = time; 039 } 040 041 //////////////////////////////////////////////////////////////////////// 042 //////////////////////////////////////////////////////////////////////// 043 044 @Override 045 public Object clone ( ) 046 //////////////////////////////////////////////////////////////////////// 047 { 048 FireEvent a1 = null; 049 050 try 051 { 052 a1 = (FireEvent)super.clone(); 053 } 054 catch (CloneNotSupportedException exception) 055 { 056 System.err.println("Clone Abort."+ exception ); 057 } 058 059 return a1; 060 } 061 062 @Override 063 public int compareTo ( final FireEvent arg0 ) 064 //////////////////////////////////////////////////////////////////////// 065 { 066 if ( time < (arg0).time) 067 { 068 return -1; 069 } 070 else if (time > (arg0).time) 071 { 072 return 1; 073 } 074 else 075 { 076 if( index < (arg0).index ) 077 { 078 return -1; 079 } 080 else if ( index > (arg0).index) 081 { 082 return 1; 083 } 084 else 085 { 086 return 0; 087 } 088 } 089 } 090 091 @Override 092 public String toString ( ) 093 //////////////////////////////////////////////////////////////////////// 094 { 095 return new String ( "time:" + time + " index:" + index); 096 } 097 098 //////////////////////////////////////////////////////////////////////// 099 //////////////////////////////////////////////////////////////////////// 100 }