두 개의 인접한 튜플을 찾는 std :: vector를 걷는 비교적 간단한 알고리즘을 사용했습니다. X 값의 왼쪽과 오른쪽 튜플을 찾으면 그것들을 삽입 할 수 있습니다. 어떻게 든이 작동이 잠시왜 2 NULL 포인터가 false로 평가되지 않습니까?
std::vector<LutTuple*>::iterator tuple_it;
LutTuple* left = NULL;
LutTuple* right = NULL;
bool found = 0;
// Only iterate as long as the points are not found
for(tuple_it = lut.begin(); (tuple_it != lut.end() && !found); tuple_it++) {
// If the tuple is less than r2 we found the first element
if((*tuple_it)->r < r) {
left = *tuple_it;
}
if ((*tuple_it)->r > r) {
right = *tuple_it;
}
if(left && right) {
found = 1;
}
}
:
std::vector<LutTuple*>::iterator tuple_it;
LutTuple* left = NULL;
LutTuple* right = NULL;
// Only iterate as long as the points are not found
for(tuple_it = lut.begin(); tuple_it != lut.end() && !left && !right; tuple_it++) {
// If the tuple is less than r2 we found the first element
if((*tuple_it)->r < r) {
left = *tuple_it;
}
if ((*tuple_it)->r > r) {
right = *tuple_it;
}
}
하지 않습니다. 왜 그런가요? 나는이 같은 두 개의 NULL ptrs가 부정 될 때 함께 true로 평가 될 것으로 기대합니다.
http://en.wikipedia.org/wiki/De_Morgan's_laws – HostileFork