System.out.println("Number threads = " + g.numThread);
- Barrier.setBarrier((int)g.numThread);
+ Barrier.setBarrier(g.numThread);
/* Create and Start Threads */
* Copyright (C) Stanford University, 2006. All Rights Reserved.
* Author: Chi Cao Minh
*
- * Ported to Java:
- * Author:Alokika dash
+ * Ported to Java June 2009 Alokika Dash
+ * adash@uci.edu
* University of California, Irvine
*
* =============================================================================
* =============================================================================
*/
public void
- bitmap_free (BitMap bitmapPtr)
+ bitmap_free ()
{
- bitmapPtr.bits = null;
- bitmapPtr = null;
+ bits = null;
//free(bitmapPtr.bits);
//free(bitmapPtr);
}
public boolean
bitmap_isSet (int i)
{
+ int val = bits[i/NUM_BIT_PER_WORD] & (1 << (i % NUM_BIT_PER_WORD));
if ((i >= 0) && (i < numBit) &&
- (bits[i/NUM_BIT_PER_WORD] & (1 << (i % NUM_BIT_PER_WORD)))) {
+ (val != 0)) {
return true;
}
int[] tmp_bits = bits;
//uint_t* bits = bitmapPtr.bits;
- for (int i = MAX(startIndex, 0); i < tmp_numBit; i++) {
- if (!(tmp_bits[i/NUM_BIT_PER_WORD] & (1 << (i % NUM_BIT_PER_WORD)))) {
+ for (int i = Math.imax(startIndex, 0); i < tmp_numBit; i++) {
+ int val = tmp_bits[i/NUM_BIT_PER_WORD] & (1 << (i % NUM_BIT_PER_WORD));
+ if(val == 0) {
return i;
}
}
int numBit = bitmapPtr.numBit;
uint_t* bits = bitmapPtr.bits;
- for (i = MAX(startIndex, 0); i < numBit; i++) {
+ for (i = Math.imax(startIndex, 0); i < numBit; i++) {
if (bits[i/NUM_BIT_PER_WORD] & (1UL << (i % NUM_BIT_PER_WORD))) {
return i;
}
}
}
*/
-
- /**
- * ======================================
- * MAX(a.b)
- * ======================================
- **/
- public int MAX(int a, int b) {
- return (a > b) ? a : b;
- }
}
/* =============================================================================
}
- public static void swap (int A[], int x, int y)
+ public void swap (int A[], int x, int y)
{
int temp = A[x];
A[x] = A[y];
// Reorganizes the given list so all elements less than the first are
// before it and all greater elements are after it.
- public static int partition(int A[], int left, int right)
+ public int partition(int a[], int left, int right)
{
int i = left - 1;
int j = right;
return i;
}
- public static void Quicksort(int A[], int f, int l)
+ public void sort(int A[], int f, int l)
{
if (f >= l) return;
int pivot_index = partition(A, f, l);
- Quicksort(A, f, pivot_index);
- Quicksort(A, pivot_index+1, l);
+ sort(A, f, pivot_index);
+ sort(A, pivot_index+1, l);
+ }
+
+ boolean less(int x, int y) {
+ return(x<y);
}
}
int size;
int capacity;
Object[] elements;
+ QuickSort qsort;
public Vector_t() {
-
+ qsort = new QuickSort();
}
/* =============================================================================
*/
public static Vector_t vector_alloc (int initCapacity) {
int capacity = Math.imax(initCapacity, 1);
- Vector_t vectorPtr = new Vector();
+ Vector_t vectorPtr = new Vector_t();
if(vectorPtr != null) {
vectorPtr.size = 0;
vectorPtr.capacity = capacity;
public void
vector_sort ()
{
- QuickSort.Quicksort(elements, 0, elements.length - 1);
+ //qsort.sort(elements, 0, (elements.length - 1));
//qsort(elements, size, 4, compare);
}