Skip to content

Commit

Permalink
Replaced ArrayList with LinkedList in the Queue class for a better ef…
Browse files Browse the repository at this point in the history
…ficiency.
  • Loading branch information
m1kc committed Nov 3, 2012
1 parent 732e847 commit 81cb6e7
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/msim/Queue.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.tomclaw.openim.main.Cookie;
import com.tomclaw.openim.main.QueueAction;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.HashMap;

/**
Expand All @@ -11,7 +11,7 @@
*/
public class Queue {

private static ArrayList actions = new ArrayList();
private static LinkedList<QueueAction> actions = new LinkedList<QueueAction>();

public void pushQueueAction(QueueAction action) {
actions.add( action );
Expand All @@ -20,9 +20,7 @@ public void pushQueueAction(QueueAction action) {
public QueueAction popQueueAction(Cookie cookie) {
System.out.println( "Actions count: " + actions.size() );

QueueAction queueAction;
for ( int c = 0; c < actions.size(); c++ ) {
queueAction = ( QueueAction ) actions.get( c );
for ( QueueAction queueAction : actions ) {
if ( queueAction != null ) {
if ( queueAction.cookie.cookieString.equals( cookie.cookieString ) ) {
System.out.println( "QueueAction found!" );
Expand All @@ -35,9 +33,7 @@ public QueueAction popQueueAction(Cookie cookie) {
}

public void runQueueAction(Cookie cookie, HashMap params) {
QueueAction queueAction;
for ( int c = 0; c < actions.size(); c++ ) {
queueAction = ( QueueAction ) actions.get( c );
for ( QueueAction queueAction : actions ) {
if ( queueAction != null ) {
if ( queueAction.cookie.cookieString.equals( cookie.cookieString ) ) {
System.out.println( "QueueAction found!" );
Expand Down

0 comments on commit 81cb6e7

Please sign in to comment.