-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.c
24 lines (18 loc) · 794 Bytes
/
search.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "index.h"
int search(NodeIndex *ind, MetaDataBuffer *bfr, uint32_t start, uint32_t end) {
uint32_t offset;
int i;
if( (ind->size > start) && (ind->index[start] != -1) ) { //If "start" isn's greater than index size and index[start] isn't empty
offset = ind->index[start]; //For all edges
do {
for(i=0;i<N;i++) { //Look for end
if( ((bfr->buffer[offset]).neighbor[i]) == end) //If end exists
return OK_SUCCESS; //Return OK_SUCCESS(edge found)
else if( ((bfr->buffer[offset]).neighbor[i]) == -1) //If neighbor is -1 go to next bucket
break;
}
offset = (bfr->buffer[offset]).nextListNode;
} while(offset != -1);
}
return FAIL; //If edge not found, return FAIL(edge not found)
}