Examples of Stack


Examples of java.util.Stack

            return (JAASRole)s.peek();
        }
       
        public static void clear ()
        {
            Stack s = (Stack)local.get();

            if ((s == null) || (s.empty()))
                return;

            s.clear();
        }
View Full Code Here

Examples of java.util.Stack

    public XMLWriterNamespaceBase(String[] uris) {
        m_uris = uris;
        m_prefixes = new String[uris.length];
        m_prefixes[0] = "";
        m_prefixes[1] = "xml";
        m_namespaceStack = new Stack();
        m_namespaceDepth = -1;
        m_translateTableStack = new Stack();
    }
View Full Code Here

Examples of java.util.Stack

  /**
   * Return an ASCII-Art representation of the tree
   */
  public String dumpStructure() {
    return dumpStructure(new Stack());
  }
View Full Code Here

Examples of java.util.Stack

            if (g != pivot) {
                sortedGeos.add(g);
            }
        }

        Stack hullStack = new Stack();
        hullStack.push(pivot);

        Geo gCross, midCross = null;
        Geo geo = null, endGeo = null, midGeo = null;

        Iterator sortedGeoIt = sortedGeos.iterator();
        if (sortedGeoIt.hasNext()) {
            midGeo = (Geo) sortedGeoIt.next();

            while (midGeo.distance(pivot) == 0 && sortedGeoIt.hasNext()) {
                midGeo = (Geo) sortedGeoIt.next();
            }
        }

        Geo lastGeoRead = midGeo;

        while (sortedGeoIt.hasNext() && midGeo != null) {
            geo = (Geo) sortedGeoIt.next();
            double dist = geo.distance(lastGeoRead);
            if (dist <= tolerance) {
                // Debug.output("Skipping duplicate geo");
                continue;
            }

            endGeo = (Geo) hullStack.peek();

            midCross = endGeo.crossNormalize(midGeo);
            gCross = midGeo.crossNormalize(geo);
            Geo i = gCross.crossNormalize(midCross).antipode();

            // Debug.output("Evaluating:\n\tendGeo: " + endGeo + "\n\tmidGeo: "
            // + midGeo + "\n\tto " + geo
            // + "\n ****** intersection point: " + i);

            if (midGeo.distance(i) < Math.PI / 2) {
                // Debug.output("+++++++++++++ midGeo to hull");

                // left turn, OK for hull
                hullStack.push(midGeo);
                endGeo = midGeo;
                midGeo = geo;

            } else {

                // right turn, need to backtrack
                while (hullStack.size() > 1) {

                    // Debug.output("-------- midGeo dropped");

                    midGeo = (Geo) hullStack.pop();
                    endGeo = (Geo) hullStack.peek();

                    midCross = endGeo.crossNormalize(midGeo);
                    gCross = midGeo.crossNormalize(geo);
                    i = gCross.crossNormalize(midCross).antipode();

                    // Debug.output("Evaluating:\n\tendGeo: " + endGeo
                    // + "\n\tmidGeo: " + midGeo + "\n\tto " + geo
                    // + "\n ****** intersection point: " + i);

                    if (midGeo.distance(i) < Math.PI / 2) {

                        // Debug.output("+++++++++++++ midGeo to hull");

                        hullStack.push(midGeo);
                        midGeo = geo;
                        break;
                    }
                }
            }

            lastGeoRead = geo;
        }

        if (midGeo != null) {
            hullStack.push(midGeo);
        }

        hullStack.push(pivot);

        Geo[] regionGeos = new Geo[hullStack.size()];

        int i = 0;
        // Need to reverse order to get inside of poly on the right side of
        // line.
        while (!hullStack.isEmpty()) {
            regionGeos[i++] = (Geo) hullStack.pop();
        }

        return regionGeos;
    }
View Full Code Here

Examples of java.util.Stack

        }

        Stack stack;

        public DirectiveStack() {
            stack = new Stack();
        }
View Full Code Here

Examples of java.util.Stack

     */
    protected synchronized ProjHolder pop() {
        ProjHolder proj = (ProjHolder)backStack.pop();

        if (forwardStack == null) {
            forwardStack = new Stack();
        }

        while (forwardStack.size() >= stackSize) {
            forwardStack.removeElementAt(0);
        }
View Full Code Here

Examples of java.util.Stack

    protected synchronized ProjHolder backPop() {
        ProjHolder proj = (ProjHolder)forwardStack.pop();

        // This has almost no chance of happening...
        if (backStack == null) {
            backStack = new Stack();
        }

        while (backStack.size() >= stackSize) {
            backStack.removeElementAt(0);
        }
View Full Code Here

Examples of java.util.Stack

    public TransactionRecoverImpl(TransactionManager txnManager) {
        this.txnManager = txnManager;
        //this.txnManager.setRecover(this);
        redoTable = new HashMap();
        redoStack = new Stack();
        stacks = 0;
    }
View Full Code Here

Examples of java.util.Stack

            logger.fatal("Failed in saveStack of recovery process: lsn = " + lsn.toString() + ".  System will in inconsistant state");
            logger.fatal("recover failed because disk is full ");
            System.exit(-1);

        }
        redoStack = new Stack();
    }
View Full Code Here

Examples of java.util.Stack

    Integer status=(Integer)statusStack.peek();
    return status.intValue();
  }
 
  public Object parse(Reader in) throws Exception{
    Stack statusStack=new Stack();
    Stack valueStack=new Stack();
    Yylex lexer=new Yylex(in);
    Yytoken token=null;
    int status=S_INIT;
   
    try{
      do{
        token=lexer.yylex();
        if(token==null)
          token=new Yytoken(Yytoken.TYPE_EOF,null);
        switch(status){
        case S_INIT:
          switch(token.type){
          case Yytoken.TYPE_VALUE:
            status=S_IN_FINISHED_VALUE;
            statusStack.push(new Integer(status));
            valueStack.push(token.value);
            break;
          case Yytoken.TYPE_LEFT_BRACE:
            status=S_IN_OBJECT;
            statusStack.push(new Integer(status));
            valueStack.push(new JSONObject());
            break;
          case Yytoken.TYPE_LEFT_SQUARE:
            status=S_IN_ARRAY;
            statusStack.push(new Integer(status));
            valueStack.push(new JSONArray());
            break;
          default:
            status=S_IN_ERROR;
          }//inner switch
          break;
         
        case S_IN_FINISHED_VALUE:
          if(token.type==Yytoken.TYPE_EOF)
            return valueStack.pop();
          else
            return null;
         
        case S_IN_OBJECT:
          switch(token.type){
          case Yytoken.TYPE_COMMA:
            break;
          case Yytoken.TYPE_VALUE:
            if(token.value instanceof String){
              String key=(String)token.value;
              valueStack.push(key);
              status=S_PASSED_PAIR_KEY;
              statusStack.push(new Integer(status));
            }
            else{
              status=S_IN_ERROR;
            }
            break;
          case Yytoken.TYPE_RIGHT_BRACE:
            if(valueStack.size()>1){
              statusStack.pop();
              JSONObject map = (JSONObject)valueStack.pop();
              map.compactify(-0.9f);
              status=peekStatus(statusStack);
            }
            else{
              status=S_IN_FINISHED_VALUE;
            }
            break;
          default:
            status=S_IN_ERROR;
            break;
          }//inner switch
          break;
         
        case S_PASSED_PAIR_KEY:
          switch(token.type){
          case Yytoken.TYPE_COLON:
            break;
          case Yytoken.TYPE_VALUE:
            statusStack.pop();
            String key=(String)valueStack.pop();
            JSONObject parent=(JSONObject)valueStack.peek();
            parent.put(key,token.value);
            status=peekStatus(statusStack);
            break;
          case Yytoken.TYPE_LEFT_SQUARE:
            statusStack.pop();
            key=(String)valueStack.pop();
            parent=(JSONObject)valueStack.peek();
            JSONArray newArray=new JSONArray();
            parent.put(key,newArray);
            status=S_IN_ARRAY;
            statusStack.push(new Integer(status));
            valueStack.push(newArray);
            break;
          case Yytoken.TYPE_LEFT_BRACE:
            statusStack.pop();
            key=(String)valueStack.pop();
            parent=(JSONObject)valueStack.peek();
            JSONObject newObject=new JSONObject();
            parent.put(key,newObject);
            status=S_IN_OBJECT;
            statusStack.push(new Integer(status));
            valueStack.push(newObject);
            break;
          default:
            status=S_IN_ERROR;
          }
          break;
         
        case S_IN_ARRAY:
          switch(token.type){
          case Yytoken.TYPE_COMMA:
            break;
          case Yytoken.TYPE_VALUE:
            JSONArray val=(JSONArray)valueStack.peek();
            val.add(token.value);
            break;
          case Yytoken.TYPE_RIGHT_SQUARE:
            if(valueStack.size()>1){
              statusStack.pop();
              valueStack.pop();
              status=peekStatus(statusStack);
            }
            else{
              status=S_IN_FINISHED_VALUE;
            }
            break;
          case Yytoken.TYPE_LEFT_BRACE:
            val=(JSONArray)valueStack.peek();
            JSONObject newObject=new JSONObject();
            val.add(newObject);
            status=S_IN_OBJECT;
            statusStack.push(new Integer(status));
            valueStack.push(newObject);
            break;
          case Yytoken.TYPE_LEFT_SQUARE:
            val=(JSONArray)valueStack.peek();
            JSONArray newArray=new JSONArray();
            val.add(newArray);
            status=S_IN_ARRAY;
            statusStack.push(new Integer(status));
            valueStack.push(newArray);
            break;
          default:
            status=S_IN_ERROR;
          }//inner switch
          break;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.