On Fri, Oct 24, 2008 at 8:16 PM,  <[EMAIL PROTECTED]> wrote:
> Author: xor
> Date: 2008-10-24 12:16:31 +0000 (Fri, 24 Oct 2008)
> New Revision: 23075
>
> Modified:
>   trunk/freenet/src/freenet/node/BandwidthUsageHistory.java
> Log:
> Implement Iterator<BandwidthUsageSample>.

Oh no!
Not yet another list implementation!

If you want a simple list, just use those in java.util.*
If you want to do something really special, make it generic and put it
under freenet.support.*
Please check if the running average class is reusable here.

> Modified: trunk/freenet/src/freenet/node/BandwidthUsageHistory.java
> ===================================================================
> --- trunk/freenet/src/freenet/node/BandwidthUsageHistory.java   2008-10-24 
> 12:14:07 UTC (rev 23074)
> +++ trunk/freenet/src/freenet/node/BandwidthUsageHistory.java   2008-10-24 
> 12:16:31 UTC (rev 23075)
> @@ -3,6 +3,7 @@
>  import java.util.Iterator;
>  import java.util.LinkedList;
>  import java.util.Date;
> +import java.util.NoSuchElementException;
>
>  /**
>  * A fixed-size list of bandwidth usage measurements. Storing a measurement
> @@ -55,21 +56,28 @@
>
>        public Iterator<BandwidthUsageSample> iterator() {
>                return new Iterator<BandwidthUsageSample>() {
> -                       int idx = (slot  - data.length) % data.length;
> +                       int idx = 0;
>
>                        public boolean hasNext() {
> -                               // TODO Auto-generated method stub
> -                               return false;
> +                               return (idx != data.length);
>                        }
>
>                        public BandwidthUsageSample next() {
> -                               // TODO Auto-generated method stub
> -                               return null;
> +                               if(!hasNext())
> +                                       throw new NoSuchElementException();
> +
> +                               // FIXME: figure out whether we should 
> clone() it.
> +                               BandwidthUsageSample result = data[(slot+idx) 
> % data.length];
> +                               ++idx;
> +                               return result;
>                        }
>
> +                       /**
> +                        * This cannot be used: The BandwidthUsageHistory 
> contains a fixed
> +                        * amount of elements.
> +                        */
>                        public void remove() {
> -                               // TODO Auto-generated method stub
> -
> +                               throw new UnsupportedOperationException();
>                        }
>
>                };
>
> _______________________________________________
> cvs mailing list
> [EMAIL PROTECTED]
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs
>
_______________________________________________
Devl mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl

Reply via email to