Beispiel #1
0
	Interfaz Red::Max(const Conj<Interfaz>& conj) const {
		assert(conj.Cardinal() > 0);

		Conj<Interfaz>::const_Iterador it = conj.CrearIt();
		Interfaz max = it.Siguiente();
		while (it.HaySiguiente()){
			if(max <= it.Siguiente()){
				max = it.Siguiente();
			}
			it.Avanzar();
		}
		return max;
	}
Beispiel #2
0
Arreglo<Posicion> Campus::DeConjAArreglo(Conj<Posicion> c) {
    Arreglo<Posicion> arreglo = Arreglo<Posicion>(c.Cardinal());
    Conj<Posicion>::Iterador itConjunto = c.CrearIt();
    Nat i = 0;
    while (itConjunto.HaySiguiente()) {
        // Copiar lo siguiente..
        if (itConjunto.Siguiente() != Posicion(-1, -1)) {
            arreglo.Definir(i, itConjunto.Siguiente());
        }
        ++i;
        itConjunto.Avanzar();
    }
    return arreglo;
}
bool campusSeguro::posCapturable(Posicion p,campus c)
{
    Conj<Posicion> vecinos = c.Vecinos(p);
    Conj<Posicion>::Iterador it = vecinos.CrearIt();
    Nat cantOcupados = 0;
    Nat cantAgentes = 0;
    while(  it.HaySiguiente() )
    {
       Posicion posVec = it.Siguiente();
       if( (grilla.Obtener(posVec)).id != 4  ){cantOcupados=cantOcupados + 1;}
       if( (grilla.Obtener(posVec)).id == 3  ){cantAgentes=cantAgentes + 1;}
       it.Avanzar();
    }
    return (cantAgentes > 0  &&  cantOcupados == vecinos.Cardinal());
}
Beispiel #4
0
	Arreglo<bool> Red::ArmarArreglo(const Conj<Interfaz>& conj) const {
		
		if(conj.Cardinal()==0){
			return Arreglo<bool>(0);
		}

		Interfaz max = Max(conj);
		Arreglo<bool> arr(max+1);
		Nat i = 0;
		
		while (i<=max){
			arr.Definir(i,false);
			i++;
		}

		return arr;
	}