Package java.util

Examples of java.util.ListIterator


    public void testIteratorSetSingleElementList() throws Exception {
        Data d1 = new Data(5);
        Data d2 = new Data(4);
        list.add(d1);

        ListIterator i = list.listIterator(0);
        i.next();
        i.set(d2);
        assertEquals(1, list.size());
        assertTrue(!i.hasNext());
        assertTrue(i.hasPrevious());
        assertEquals(d2, i.previous());
        assertTrue(i.hasNext());
        assertTrue(!i.hasPrevious());
        assertEquals(d2, i.next());
    }
View Full Code Here


        assertEquals(d2, i.next());
    }

    @Test
    public void testIteratorAddEmptyList() throws Exception {
        ListIterator i = list.listIterator();
        Data d1 = new Data(5);
        assertTrue(!i.hasPrevious());
        assertTrue(!i.hasNext());
        i.add(d1);
        assertTrue(i.hasPrevious());
        assertTrue(!i.hasNext());
        assertEquals(d1, i.previous());
        assertEquals(d1, i.next());
        assertEquals(d1, list.get(0));
    }
View Full Code Here

        for (int i = 0; i < data.length; i++) {
            data[i] = new Data(i);
            list.add(data[i]);
        }

        ListIterator i;

        i = list.listIterator(5);
        i.next();
        i.remove();
        Data d = new Data(6);
        assertEquals(d, list.get(5));
    }
View Full Code Here

  if ( encoding.equals("PkiPath") )
  {
        ASN1EncodableVector v = new ASN1EncodableVector();

    // TODO check ListIterator  implementation for JDK 1.1
      ListIterator iter = certificates.listIterator(certificates.size());
      while ( iter.hasPrevious() )
      {
        v.add(getEncodedX509Certificate((X509Certificate)iter.previous()));
      }

        encoded = new DERSequence(v);
  }
  else
View Full Code Here

   
    int[]  totals       = new int[sample_end];
    short[]  hits      = new short[sample_end];       
    short[]  worst_var_type  = new short[sample_end];
                     
    ListIterator sample_it = regions.listIterator( 0 );
     
      // flatten out all observations into a single munged metric

    while( sample_it.hasNext()){
     
      region r = (region)sample_it.next();
   
      int  start   = (up?r.getUploadStartBytesPerSec():r.getDownloadStartBytesPerSec())/SPEED_DIVISOR;
      int  end    = (up?r.getUploadEndBytesPerSec():r.getDownloadEndBytesPerSec())/SPEED_DIVISOR;
      int  metric  = r.getMetric();
   
View Full Code Here

            ((Graphics2D) gr).fill(shp);
            setGraphicsForEdge(gr);
            ((Graphics2D) gr).draw(shp);

        } else {
            ListIterator iterator;
            java.util.List targets = getTargets();
            OMGeometry geometry;

            if (traverseMode == FIRST_ADDED_ON_TOP) {
                iterator = targets.listIterator(targets.size());
                while (iterator.hasPrevious()) {
                    geometry = (OMGeometry) iterator.previous();

                    if (geometry.isVisible()) {
                        renderGeometry(geometry, gr);
                    }

                }
            } else {
                iterator = targets.listIterator();
                while (iterator.hasNext()) {
                    geometry = (OMGeometry) iterator.next();

                    if (geometry.isVisible()) {
                        renderGeometry(geometry, gr);
                    }
                }
View Full Code Here

        // Important! Resets the shape.
        shape = null;

        // Create a shape object out of all of the shape objects.
        ListIterator iterator;

        if (traverseMode == FIRST_ADDED_ON_TOP) {
            iterator = graphics.listIterator(graphics.size());
            while (iterator.hasPrevious()) {
                updateShape((OMGeometry) iterator.previous(),
                        p,
                        forceProjectAll);
            }
        } else {
            iterator = graphics.listIterator();
            while (iterator.hasNext()) {
                updateShape((OMGeometry) iterator.next(), p, forceProjectAll);
            }
        }
        setNeedToRegenerate(false);
    }
View Full Code Here

     *
     * @param gr the AWT Graphics context
     */
    public synchronized void render(Graphics gr) {
        OMGraphic graphic;
        ListIterator iterator;

        if (isVague() && !isVisible())
            return;

        if (traverseMode == FIRST_ADDED_ON_TOP) {
            iterator = graphics.listIterator(graphics.size());
            while (iterator.hasPrevious()) {
                graphic = (OMGraphic) iterator.previous();
                if (shouldProcess(graphic)) {
                    graphic.render(gr);
                }
            }

        } else {
            iterator = graphics.listIterator();

            while (iterator.hasNext()) {
                graphic = (OMGraphic) iterator.next();
                if (shouldProcess(graphic)) {
                    graphic.render(gr);
                }
            }
        }
View Full Code Here

     *
     * @param gr the AWT Graphics context
     */
    public synchronized void renderAllAsSelected(Graphics gr) {
        OMGraphic graphic;
        ListIterator iterator;

        if (traverseMode == FIRST_ADDED_ON_TOP) {
            iterator = graphics.listIterator(graphics.size());
            while (iterator.hasPrevious()) {
                graphic = (OMGraphic) iterator.previous();
                if (shouldProcess(graphic)) {
                    graphic.select();
                    graphic.render(gr);
                    graphic.deselect();
                }
            }

        } else {
            iterator = graphics.listIterator();

            while (iterator.hasNext()) {
                graphic = (OMGraphic) iterator.next();
                if (shouldProcess(graphic)) {
                    graphic.select();
                    graphic.render(gr);
                    graphic.deselect();
                }
View Full Code Here

     */
    protected synchronized OMDist _findClosest(int x, int y, float limit,
                                               boolean resetSelect) {
        OMDist omd = new OMDist();
        OMDist tomd;
        ListIterator iterator;
        int i;

        if (size() != 0) {
            if (traverseMode == FIRST_ADDED_ON_TOP) {
                i = 0;
                iterator = graphics.listIterator();
                while (iterator.hasNext()) {
                    tomd = findClosestTest(omd,
                            i++,
                            (OMGeometry) iterator.next(),
                            x,
                            y,
                            limit,
                            resetSelect);
                    if (tomd == null)
                        continue;
                    omd = tomd; // for style
                    if (omd.d == 0)
                        break;
                }
            } else {
                i = graphics.size();
                iterator = graphics.listIterator(i);
                while (iterator.hasPrevious()) {
                    tomd = findClosestTest(omd,
                            i--,
                            (OMGeometry) iterator.previous(),
                            x,
                            y,
                            limit,
                            resetSelect);
                    if (tomd == null)
View Full Code Here

TOP

Related Classes of java.util.ListIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.