HashSet riverHexes = new HashSet();
HashSet<IHex> riverHexes = new HashSet<IHex>();
    public static void addRiver(IBoard board, HashMap reverseHex) {        int minElevation = Integer.MAX_VALUE;        HashSet riverHexes = new HashSet();        IHex field;        Point p = null;        int direction = 0;        int nextLeft = 0;        int nextRight = 0;                int width = board.getWidth();        int height = board.getHeight();                /* if map is smaller than 5x5 no real space for an river */        if ((width < 5) || (height < 5)) {            return;        }        /* First select start and the direction */        switch (Compute.randomInt(4)) {        case 0:            p = new Point(0, Compute.randomInt(5) - 2 + height / 2);            direction = Compute.randomInt(2) + 1;            nextLeft = direction - 1;            nextRight = direction + 1;            break;        case 1:            p = new Point(width - 1, Compute.randomInt(5) - 2 + height / 2);            direction = Compute.randomInt(2) + 4;            nextLeft = direction - 1;            nextRight = (direction + 1) % 6;            break;        case 2:        case 3:            p = new Point(Compute.randomInt(5) - 2 + width / 2, 0);            direction = 2;            nextRight = 3;            nextLeft = 4;            break;        } // switch        /* place the river */        field = board.getHex(p.x, p.y);        ITerrainFactory f = Terrains.getTerrainFactory();                do {            /* first the hex itself */            field.removeAllTerrains();            field.addTerrain(f.createTerrain(Terrains.WATER, 1));            riverHexes.add(field);            p = (Point)reverseHex.get(field);            /* then maybe the left and right neighbours */            riverHexes.addAll(extendRiverToSide(board, p, Compute.randomInt(3),                     nextLeft, reverseHex));            riverHexes.addAll(extendRiverToSide(board, p, Compute.randomInt(3),                    nextRight, reverseHex));            switch (Compute.randomInt(4)) {            case 0:                 field = board.getHexInDir(p.x, p.y, (direction + 5) % 6);                break;            case 1:                 field = board.getHexInDir(p.x, p.y, (direction + 1) % 6);                break;            default:                field = board.getHexInDir(p.x, p.y, direction);            break;            }                    } while (field != null);                 /* search the elevation for the river */        HashSet tmpRiverHexes = (HashSet)riverHexes.clone();        while (!tmpRiverHexes.isEmpty()) {            Iterator iter = tmpRiverHexes.iterator();            field = (IHex)iter.next();            if (field.getElevation() < minElevation) {                minElevation = field.getElevation();            }            tmpRiverHexes.remove(field);            Point thisHex = (Point)reverseHex.get(field);            /* and now the six neighbours */            for (int i = 0; i < 6; i++) {                field = board.getHexInDir(thisHex.x, thisHex.y, i);                if ((field != null) && (field.getElevation() < minElevation)) {                    minElevation = field.getElevation();                }                tmpRiverHexes.remove(field);            }        }                /* now adjust the elevation to same height */        Iterator iter = riverHexes.iterator();        while (iter.hasNext()) {            field = (IHex)iter.next();            field.setElevation(minElevation);        }                return;    }