Algorithm-VSM

 view release on metacpan or  search on metacpan

examples/corpus/MultiCustomerAccount.java  view on Meta::CPAN



//MultiCustomerAccount.java

///////////////////////////  class Account  ///////////////////////////
class Account {                                                   //(A)
    int balance;                                                  //(B)

    Account() { balance = 0; }                                    //(C)

    synchronized void deposit( int dep ){                         //(D)
        balance += dep;                                           //(E)
        notifyAll();                                              //(F)
    }
    synchronized void withdraw( int draw ) {                      //(G)
        while ( balance < draw ) {                                //(H)
            try { 
                wait();                                           //(I)
            } catch( InterruptedException e ) {}
        }
        balance -= draw;                                          //(J)
    }
}

//////////////////////////  class Depositor  //////////////////////////

examples/corpus/SynchedFileIO.java  view on Meta::CPAN


//SynchedFileIO.java

///////////////////////////  class DataFile  //////////////////////////
class DataFile {
    public DataFile() {
        try {
            FileIO.writeOneString( "Hello", "hello.dat" );      
        } catch( FileIOException e ) {}
    }
    synchronized void fileIO() {
        try {
            String str = FileIO.readOneString( "hello.dat" );
            FileIO.writeOneString( str  , "hello.dat" );
        } catch( FileIOException e ) {}
    }
}


////////////////////////  class ThreadedFileIO  ///////////////////////
class ThreadedFileIO extends Thread  {

examples/corpus/SynchedSwaps.java  view on Meta::CPAN


//////////////////////////  class DataObject  /////////////////////////
class DataObject {
    int dataItem1;
    int dataItem2;

    DataObject() {
        dataItem1 = 50;
        dataItem2 = 50;
    }
    synchronized void itemSwap() {
        int x = (int) ( -4.999999 + Math.random() * 10 );
        dataItem1 -= x;
        keepBusy(10);                                     
        dataItem2 += x;
    }
    synchronized void test() {
        int sum = dataItem1 + dataItem2;
        System.out.println( sum );    
    }
    public void keepBusy( int howLong ) {
        long curr = System.currentTimeMillis();            
        while ( System.currentTimeMillis() < curr + howLong )
            ;
    }
}

examples/corpus_with_java_and_cpp/ClientSocket.cc  view on Meta::CPAN

             this,   SLOT( getWebPage() ) );

    connect( socket, SIGNAL( connectionClosed() ),
             this,   SLOT( socketConnectionClosed() ) );

    connect( socket, SIGNAL( error( int ) ),
             this,   SLOT( reportError( int ) ) );

    QString qstr( wwwName.c_str() );

    socket->connectToHost( qstr, 80 );   // asynchronous call
}

ClientSocket::~ClientSocket() {}

string ClientSocket::constructHttpRequest( ) {
    string hostHeader = "Host: " + wwwName;
    string urlString( hostHeader );
    string httpRequestString = "GET / HTTP/1.0\r\n" + 
                               urlString + "\r\n" + "\r\n";
    return httpRequestString;

examples/corpus_with_java_and_cpp/MultiCustomerAccount.java  view on Meta::CPAN



//MultiCustomerAccount.java

///////////////////////////  class Account  ///////////////////////////
class Account {                                                   //(A)
    int balance;                                                  //(B)

    Account() { balance = 0; }                                    //(C)

    synchronized void deposit( int dep ){                         //(D)
        balance += dep;                                           //(E)
        notifyAll();                                              //(F)
    }
    synchronized void withdraw( int draw ) {                      //(G)
        while ( balance < draw ) {                                //(H)
            try { 
                wait();                                           //(I)
            } catch( InterruptedException e ) {}
        }
        balance -= draw;                                          //(J)
    }
}

//////////////////////////  class Depositor  //////////////////////////

examples/corpus_with_java_and_cpp/SynchedFileIO.java  view on Meta::CPAN


//SynchedFileIO.java

///////////////////////////  class DataFile  //////////////////////////
class DataFile {
    public DataFile() {
        try {
            FileIO.writeOneString( "Hello", "hello.dat" );      
        } catch( FileIOException e ) {}
    }
    synchronized void fileIO() {
        try {
            String str = FileIO.readOneString( "hello.dat" );
            FileIO.writeOneString( str  , "hello.dat" );
        } catch( FileIOException e ) {}
    }
}


////////////////////////  class ThreadedFileIO  ///////////////////////
class ThreadedFileIO extends Thread  {

examples/corpus_with_java_and_cpp/SynchedSwaps.java  view on Meta::CPAN


//////////////////////////  class DataObject  /////////////////////////
class DataObject {
    int dataItem1;
    int dataItem2;

    DataObject() {
        dataItem1 = 50;
        dataItem2 = 50;
    }
    synchronized void itemSwap() {
        int x = (int) ( -4.999999 + Math.random() * 10 );
        dataItem1 -= x;
        keepBusy(10);                                     
        dataItem2 += x;
    }
    synchronized void test() {
        int sum = dataItem1 + dataItem2;
        System.out.println( sum );    
    }
    public void keepBusy( int howLong ) {
        long curr = System.currentTimeMillis();            
        while ( System.currentTimeMillis() < curr + howLong )
            ;
    }
}

examples/test_queries.txt  view on Meta::CPAN

q4:  Cloneable CloneNotSupportedException xobj_clone array random printstring

q5:  getName user maryjo jojo StudentUser user derived base invoke

q6:  swing actionPerformed closeButton startButton windowClosing greetingButton

q7:  pane MyTextPanel jpanel insertUpdate

q8:  threading ThreadFileIO extends datafile readOneString InterruptedException

q9:  synchronized withdraw balance Withdrawer random Math Account Depositor

q10: ChatServer ServerSocket exception clientHandler clientList ArrayList

q11: ListIterator InputStreamReader getOutputStream exception flush 

q12: newInstance driver executeQuery insert executeQuery resultSetMetaData 

q13: autocommit drop table friends sportsclub primary sport getString

q14: duplcatebase virtual nonvirtual operator subobject printing



( run in 0.462 second using v1.01-cache-2.11-cpan-0d8aa00de5b )