Package java.util

Examples of java.util.Queue


    String s = new String("\nProgram Dependence Graph for Method " + this.m_body.getMethod().getName());
    s += "\n*********CFG******** \n" + this.m_regionAnalysis.CFGtoString(this.m_blockCFG, true);
    s += "\n*********PDG******** \n";
   
    List<PDGNode> processed = new ArrayList<PDGNode>();
    Queue nodes = new LinkedList();
    nodes.offer(this.m_startNode);
   
    while(nodes.peek() != null)
    {
      PDGNode node = (PDGNode) nodes.remove();
      processed.add(node);
     
      s += "\n Begin PDGNode: " + node;
      List succs = this.getSuccsOf(node);
      s += "\n has " + succs.size() + " successors:\n";
     
      int i = 0;
      Iterator itr = succs.iterator();
      while(itr.hasNext())
      {
        PDGNode succ = (PDGNode)itr.next();
        List labels = this.getLabelsForEdges(node, succ);
       
        s += i++;
        s += ": Edge's label: " + labels + " \n";
        s += "   Target: " + succ.toShortString();
        s += "\n";
       
        if(labels.get(0).equals("dependency"))
        if(!processed.contains(succ))
          nodes.offer(succ);
       
      }
     
      s += "\n End PDGNode.";
     
View Full Code Here


        try {
            final PackageBuilder packageBuilder = new PackageBuilder();
            packageBuilder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_MultithreadFiringCheck.drl" ) ) );
            final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
            ruleBase.addPackage( packageBuilder.getPackage() );
            final Queue errorList = new ConcurrentLinkedQueue();
            final Thread t[] = new Thread[50];
            for ( int i = 0; i < t.length; i++ ) {
                final int count = i;
                t[i] = new Thread( new Runnable() {
                    public void run() {
                        try {
                            final int iterations = count * 15 + 3000;
                            final List results = new ArrayList();
                            final StatefulSession session2 = ruleBase.newStatefulSession();
                            session2.setGlobal( "results",
                                                results );
                            session2.insert( new Integer( -1 ) );
                            for ( int k = 0; k < iterations; k++ ) {
                                session2.insert( new Integer( k ) );
                                if ( k + 1 != session2.getAgenda().agendaSize() ) {
                                    errorList.add( "THREAD-" + count + " ERROR: expected agenda size=" + (k + 1) + " but was " + session2.getAgenda().agendaSize() );
                                }
                            }
                            session2.fireAllRules();
                            session2.dispose();
                            if ( results.size() != iterations ) {
                                errorList.add( "THREAD-" + count + " ERROR: expected fire count=" + iterations + " but was " + results.size() );
                            }
                        } catch ( Exception e ) {
                            errorList.add( "THREAD-" + count + " EXCEPTION: " + e.getMessage() );
                            e.printStackTrace();
                        }
                    }
                } );
                t[i].start();
            }
            for ( int i = 0; i < t.length; i++ ) {
                t[i].join();
            }
            assertTrue( "Errors during execution: " + errorList.toString(),
                        errorList.isEmpty() );
        } catch ( Exception e ) {
            e.printStackTrace();
            fail( "No exception should have been raised: "+e.getMessage());
        }
    }
View Full Code Here

    }

    public static void readActionQueue(MarshallerReaderContext context) throws IOException, ClassNotFoundException {
        ReteooWorkingMemory wm = (ReteooWorkingMemory) context.wm;
        Queue actionQueue = wm.getActionQueue();
        while ( context.readShort() == PersisterEnums.WORKING_MEMORY_ACTION ) {
            actionQueue.offer( PersisterHelper.readWorkingMemoryAction( context ) );
        }
    }
View Full Code Here

     * @throws Exception
     */
    protected Object doExecute() throws Exception {
        JaasRealm realm = (JaasRealm) session.get(JAAS_REALM);
        AppConfigurationEntry entry = (AppConfigurationEntry) session.get(JAAS_ENTRY);
        Queue commandQueue = (Queue) session.get(JAAS_CMDS);

        if (realm != null && entry != null) {
            if (commandQueue != null) {
                commandQueue.add(this);
            }
        } else {
            System.err.println("No JAAS Realm / Module has been selected.");
        }
        return null;
View Full Code Here

    }

    public static void readActionQueue(MarshallerReaderContext context) throws IOException {
        ReteooWorkingMemory wm = (ReteooWorkingMemory) context.wm;
        Queue actionQueue = wm.getActionQueue();
        while ( context.readShort() == PersisterEnums.WORKING_MEMORY_ACTION ) {
            actionQueue.offer( PersisterHelper.readWorkingMemoryAction( context ) );
        }
    }
View Full Code Here

    }

    public static void readActionQueue(MarshallerReaderContext context) throws IOException, ClassNotFoundException {
        ReteooWorkingMemory wm = (ReteooWorkingMemory) context.wm;
        Queue actionQueue = wm.getActionQueue();
        while ( context.readShort() == PersisterEnums.WORKING_MEMORY_ACTION ) {
            actionQueue.offer( PersisterHelper.readWorkingMemoryAction( context ) );
        }
    }
View Full Code Here

            root = rootDirectory;
        }

        // Use a queue to ensure depth first searching across the directories.
        // Without this it would lead to a unbalanced structure.
        Queue queue = new LinkedList();
        Directory directory;

        // Try all of the directories in a breadth first order, hence the
        // reason for the queue to see if any of them can allocate a file.
        queue.add(root);
        while ((directory = (Directory) queue.poll()) != null) {
            File newFile = directory.allocateFile(queue);
            if (newFile != null) {
                return newFile;
            }
        }

        // None of them could so now try all of the directories to see if any
        // of them can allocate a directory.
        queue.add(root);
        while ((directory = (Directory) queue.poll()) != null) {

            Directory newDirectory = directory.allocateDirectory(queue);
            if (newDirectory != null) {
                File newFile = newDirectory.allocateFile(null);
                if (newFile != null) {
View Full Code Here

     * @throws Exception
     */
    protected Object doExecute() throws Exception {
        JaasRealm realm = (JaasRealm) session.get(JAAS_REALM);
        AppConfigurationEntry entry = (AppConfigurationEntry) session.get(JAAS_ENTRY);
        Queue commandQueue = (Queue) session.get(JAAS_CMDS);

        if (realm != null && entry != null) {
            if (commandQueue != null) {
                commandQueue.add(this);
            }
        } else {
            System.err.println("No JAAS Realm / Module has been selected.");
        }
        return null;
View Full Code Here

   
  }
 
  public void sendTestMoves(){
    System.out.println("PLAYER 2 WRITING MOVES TO SERVER");
    Queue test = new LinkedList<String>();
    for(int i = 0; i<1000;i++){
      test.add("down");
    }
    try {
      obj1Out.writeObject(test);
    } catch (IOException e) {
      // TODO Auto-generated catch block
View Full Code Here

     * @throws Exception
     */
    protected Object doExecute() throws Exception {
        JaasRealm realm = (JaasRealm) session.get(JAAS_REALM);
        AppConfigurationEntry entry = (AppConfigurationEntry) session.get(JAAS_ENTRY);
        Queue commandQueue = (Queue) session.get(JAAS_CMDS);

        if (realm != null && entry != null) {
            if (commandQueue != null) {
                commandQueue.add(this);
            }
        } else {
            System.err.println("No JAAS Realm / Module has been selected");
        }
        return null;
View Full Code Here

TOP

Related Classes of java.util.Queue

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.