Skip to content
Browse files

Add peek() to RingQueue.

  • Loading branch information...
1 parent 17ff19c commit fb79fe150e395aa1ee9b6d5cad09bbb58bf12c00 @krestenkrab committed May 6, 2010
Showing with 14 additions and 0 deletions.
  1. +14 −0 src/kilim/RingQueue.java
View
14 src/kilim/RingQueue.java
@@ -18,6 +18,20 @@ public RingQueue(int initialSize, int maxSize) {
public int size() {return size;}
+ public T peek() {
+ T elem;
+ T[] elems;
+ int n = size;
+ if (n > 0) {
+ elems = elements;
+ int ic = icons;
+ elem = elems[ic];
+ } else {
+ elem = null;
+ }
+ return elem;
+ }
+
public T get() {
T elem;
T[] elems;

0 comments on commit fb79fe1

Please sign in to comment.
Something went wrong with that request. Please try again.