Sha256: 59ebf9b2a2d1b7657b9a2b1bcc7943dd4bcdea82f35f632b775245a76285a241

Contents?: true

Size: 775 Bytes

Versions: 7

Compression:

Stored size: 775 Bytes

Contents

package org.jbox2d.particle;


public class StackQueue<T> {

  private T[] m_buffer;
  private int m_front;
  private int m_back;
  private int m_end;

  public StackQueue() {}

  public void reset(T[] buffer) {
    m_buffer = buffer;
    m_front = 0;
    m_back = 0;
    m_end = buffer.length;
  }

  public void push(T task) {
    if (m_back >= m_end) {
      System.arraycopy(m_buffer, m_front, m_buffer, 0, m_back - m_front);
      m_back -= m_front;
      m_front = 0;
      if (m_back >= m_end) {
        return;
      }
    }
    m_buffer[m_back++] = task;
  }

  public T pop() {
    assert (m_front < m_back);
    return m_buffer[m_front++];
  }

  public boolean empty() {
    return m_front >= m_back;
  }

  public T front() {
    return m_buffer[m_front];
  }
}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pbox2d-1.0.3-java src/org/jbox2d/particle/StackQueue.java
pbox2d-1.0.2-java src/org/jbox2d/particle/StackQueue.java
pbox2d-1.0.1-java src/org/jbox2d/particle/StackQueue.java
pbox2d-1.0.0-java src/org/jbox2d/particle/StackQueue.java
pbox2d-0.9.1-java src/org/jbox2d/particle/StackQueue.java
pbox2d-0.9.0-java src/org/jbox2d/particle/StackQueue.java
pbox2d-0.8.0-java src/org/jbox2d/particle/StackQueue.java