public void track() { Trace current = new Trace(); synchronized(this) { Trace exist = get(current.id); if (exist != null) { exist.count++; } else { put(current.id, current); } } } }
Trace() { super(); id = calculateIdentifier(); } private long calculateIdentifier() {
private long calculateIdentifier() { int len = 0; for (int i=0; i<this.getStackTrace().length; i++) { len += this.getStackTrace()[i].toString().intern().hashCode(); } return len; } }
Trace t1 = new Trace(); t1.setDescription("description_1"); t1.setTimestamp(System.currentTimeMillis()); traces.add(t1); Trace t2 = new Trace(); t2.setDescription("description_2"); t2.setTimestamp(System.currentTimeMillis()); traces.add(t2);
public void track() { Trace current = new Trace(); synchronized(this) { Trace exist = get(current.id); if (exist != null) { exist.count++; } else { put(current.id, current); } } } }
Trace() { super(); id = calculateIdentifier(); } private long calculateIdentifier() {
private long calculateIdentifier() { int len = 0; for (int i=0; i<this.getStackTrace().length; i++) { len += this.getStackTrace()[i].toString().intern().hashCode(); } return len; } }
public void track() { Trace current = new Trace(); synchronized(this) { Trace exist = get(current.id); if (exist != null) { exist.count++; } else { put(current.id, current); } } } }
Trace() { super(); id = calculateIdentifier(); } private long calculateIdentifier() {
private long calculateIdentifier() { int len = 0; for (int i=0; i<this.getStackTrace().length; i++) { len += this.getStackTrace()[i].toString().intern().hashCode(); } return len; } }
public void track() { Trace current = new Trace(); synchronized(this) { Trace exist = get(current.id); if (exist != null) { exist.count++; } else { put(current.id, current); } } } }
Trace() { super(); id = calculateIdentifier(); } private long calculateIdentifier() {
private long calculateIdentifier() { int len = 0; for (int i=0; i<this.getStackTrace().length; i++) { len += this.getStackTrace()[i].toString().intern().hashCode(); } return len; } }
public void track() { Trace current = new Trace(); synchronized(this) { Trace exist = get(current.id); if (exist != null) { exist.count++; } else { put(current.id, current); } } } }
Trace() { super(); id = calculateIdentifier(); } private long calculateIdentifier() {
private long calculateIdentifier() { int len = 0; for (int i=0; i<this.getStackTrace().length; i++) { len += this.getStackTrace()[i].toString().intern().hashCode(); } return len; } }
static void addToQueue2(int value, Trace currentTrace, LinkedList<Trace> queue) { Trace nt = new Trace(value); nt.path = (LinkedList<Integer>)currentTrace.path.clone(); nt.path.addFirst(value); queue.addLast(nt); } static LinkedList<Integer> findPath2(int from, int to) throws Exception { if (from < to) throw new Exception("from < to"); LinkedList<Trace> q = new LinkedList<Trace>(); Trace t = new Trace(to); t.path.addFirst(to); q.addLast(t); while (!q.isEmpty()) { Trace e = q.getFirst(); q.removeFirst(); int cv = e.currentValue; if (cv == from) return e.path; if (cv > from) continue; addToQueue2(cv+1, e, q); addToQueue2(cv*3, e, q); addToQueue2(cv*5, e, q); } throw new Exception("no path"); }