All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bixuebihui.util.Queue Maven / Gradle / Ivy

package com.bixuebihui.util;

import java.util.Vector;

/**
 * 

Queue class.

* * @author xingwx * @version $Id: $Id */ public class Queue { /** *

dequeue.

* * @return a {@link java.lang.Object} object. */ public synchronized Object dequeue() { if (empty()) { return null; } else { Object obj = v.firstElement(); v.removeElementAt(0); return obj; } } /** *

enqueue.

* * @param obj a T object. */ public void enqueue(T obj) { v.addElement(obj); } /** *

size.

* * @return a int. */ public int size() { return v.size(); } /** *

empty.

* * @return a boolean. */ public boolean empty() { return v.size() < 1; } /** *

Constructor for Queue.

*/ public Queue() { v = new Vector(); } /** *

Constructor for Queue.

* * @param i a int. */ public Queue(int i) { v = new Vector(i); } private final Vector v; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy