Code example for Stack

Methods: add, clear, firstElement

0
	// =========================================================== 
 
	private void init(final String pLabel) {
		final long now = System.currentTimeMillis();
		final DebugTime debugTime = new DebugTime(now, pLabel);
		this.mDebugTimes.add(debugTime);
	} 
 
	public void begin(final String pLabel) {
		final long now = System.currentTimeMillis();
		final DebugTime debugTime = new DebugTime(now, pLabel);
		this.mDebugTimes.peek().begin(debugTime);
		this.mDebugTimes.add(debugTime);
	} 
 
	public void split(final String pLabel) {
		this.mDebugTimes.peek().split(pLabel);
	} 
 
	public void end() { 
		final long now = System.currentTimeMillis();
		if(this.mDebugTimes.size() == 1) {
			throw new IllegalStateException("Cannot end the root of this " + this.getClass().getSimpleName());
		} else { 
			this.mDebugTimes.pop().end(now);
		} 
	} 
 
	public void dump() { 
		this.dump(false);
	} 
 
	public void dump(final boolean pClear) {
		final long now = System.currentTimeMillis();
		if(this.mDebugTimes.size() > 1) {
			Debug.w(this.getClass().getSimpleName() + " not all ended!");
		} 
 
		final DebugTime root = this.mDebugTimes.firstElement();
		root.end(now);
		root.dump(0);
 
		if(pClear) {
			this.clear();
		} 
	} 
 
	public void clear() { 
		final DebugTime root = this.mDebugTimes.firstElement();
		this.mDebugTimes.clear();
		this.init(root.mLabel);
	} 
 
	// =========================================================== 
	// Inner and Anonymous Classes