programming

Abstraction vs. Semantic

Different Semantic, Same Abstraction

The following two functions have the same semantics, but use different abstractions:

void swap(int[] a, int i, int j) {
	int h = a[i];
	a[i] = a[j];
	a[j] = h;
}
void swap(int[] a, int i, int j) {
	a[i] ^= a[j];
	a[j] ^= a[i];
	a[i] ^= a[j];
}