void print() {
		for (int i = 0; i < t.size(); i++){
			cout << *(t[i].first);
			if (i!=t.size()-1) cout<< " => ";
			
		}
		cout << ", " << rank << endl;
	}
Ejemplo n.º 2
0
double myVector::computeAngle(myVector target)
{
    double l1=length();
    double l2=target.length();
    double l3=dist(target);
    return acos((l1*l1+l2*l2-l3*l3)/(2*l1*l2));
}
	bool feasible(int city) {
		for (int i = 0; i < t.size(); i++) {
			if (*(t[i].first) == city)
				return false;
		}
		return true;
	}
	void remove_last_city() {
		rank -= t.back().second;
		t.pop_back();
	}
	city last_city() {
		return t.back();
	}
	long size() {
		return t.size();
	}
	void insert(city c) {
		t.push_back(c);
		rank += c.second;
	}
	Tour(city id) {
		rank = id.second;
		t.push_back(id);
	}
Ejemplo n.º 9
0
template<class T> void testfunction(myVector<T>& test, const T& val, const T& halla) {
    
    test.push_back(val);
    test.push_back(halla);
    test.push_back(halla);
    
    myVector<T> testcopy;
    testcopy = myVector<T>(test); //Test Zuweisungsoperator und Copykonstruktor
    
    for(size_t i(0U); i<test.size(); i++){
        std::cout << "Vektorinhalt: '" << test[i] << "'; ";
        std::cout << "Kopierter Vektorinhalt: '" << testcopy[i] << "'" << std::endl;
    }
        
    std::cout << "Wert am Index 2: " << test.get(2) << std::endl;
    test.set(2, val);
    std::cout << "Wert am Index 2 nach set(): " << test.get(2) << std::endl;
    std::cout << "Wert am Index 1: " << test[1] << std::endl;
    std::cout << "Wert am Index 0: " << test.get(0) << std::endl;
    std::cout << "Wert am Index 1 mit at(): " << test.at(1) << std::endl;
    std::cout << "Vektorgroesse: " << test.size() << std::endl;
    std::cout << "Vektorkapazitaet: " << test.capacity() << std::endl;
    test.resize(15);
    std::cout << "Vektorgroesse nach resize(): " << test.size() << std::endl;
    std::cout << "Vektorkapazitaet nach resize(): " << test.capacity() << std::endl;
    test.reserve(20);
    std::cout << "Vektorkapazitaet nach reverse(): " << test.capacity() << std::endl;
    
}