package com.aos.config;

import java.util.Arrays;

public class VectorClock {

	private int[] vc;
	private int myId;
	private int numProc;
	/**
	 * This is a modified version of Vector clock. This Vector
	 * clock only takes care of number of messages received by process
	 * Pi to Pj
	 * 
	 * @param myId
	 * @param numProc
	 */
	public VectorClock(int myId, int numProc) {
		super();
		this.myId = myId;
		this.numProc = numProc;
		// Initialize Vector clock
		this.vc = new int[numProc];
		for(int i = 0; i < numProc; i++) this.vc[i] = 0;
	}

	public synchronized int[] getVectorClock(){
		return this.vc;
	}
	
	public synchronized int getVectorClockValue(int i){
		return this.vc[i];
	}
	
	public synchronized void sendEvent(){
		this.vc[this.myId]++;
	}
/*	
	public synchronized void receiveEvent(int j, int receivedValue){
		this.vc[j] = this.max(this.vc[j], receivedValue);
		this.vc[this.myId] = this.max(this.vc[this.myId], receivedValue) + 1;
	}
*/
	public synchronized void receiveEvent(int[] received){
		for(int k = 0; k < numProc; k++)
			this.vc[k] = this.max(this.vc[k], received[k]);
		this.vc[this.myId]++;
	}
	
	private int max(int a, int b){ return (a > b) ? a : b; }

	@Override
	public String toString() {
		return "VectorClock " + Arrays.toString(vc);
	}
	
}

@@ -132,16 +132,18 @@
 umProc;%0A
+%09%0A
 %09/**%0A%09 *
@@ -147,144 +147,51 @@
 %09 * 
-This is a modified version of Vector clock. This
+Implementation of Fidge/Martin
  Vector
-%0A%09 *
  clock
- only takes care of number of messages received by process%0A%09 * Pi to Pj
 %0A%09 *
@@ -665,207 +665,9 @@
 %0A%09%7D%0A
-/*%09%0A%09public synchronized void receiveEvent(int j, int receivedValue)%7B%0A%09%09this.vc%5Bj%5D = this.max(this.vc%5Bj%5D, receivedValue);%0A%09%09this.vc%5Bthis.myId%5D = this.max(this.vc%5Bthis.myId%5D, receivedValue) + 1;%0A%09%7D%0A*/
+%09
 %0A%09pu

Remove dead code