public synchronized void push(Object elem) {
if (m_end==m_elements.length) {
// we are full but not warped,
// can we warp around?
if (m_pos==0) {
// no... therefore just grow.
grow();
} else {
// yes, warp;
m_end = 0;
}
m_elements[m_end++] = elem;
return;
}
if (m_pos< =m_end) {
// we are not wrapped and we
// are not full (above test)...
// just add the event.
m_elements[m_end++] = elem;
return;
}
// we are wrapped...
if (m_end==m_pos-1) {
// we are warpped and full, grow.
grow();
}
m_elements[m_end++] = elem;
}
|