Пример #1
0
list* addRowToTable(list* row, list* table){
	list* tableDown=table->down;
	if(tableDown==NULL){
		tableDown= (list*) malloc(sizeof(list));
		table->down= tableDown;
	}
	list* searchNode=searchRight(row->nodeName, tableDown);
	if(searchNode==NULL){

		list* newNode=createListNode(row->nodeName);
		copyAttributes(newNode,row->attrList);
		addRight(newNode, tableDown);
		
		list*rowColumns= row->down;
		if(rowColumns==NULL || rowColumns->right==NULL){
			yyerror("ERROR\n");
		}
		rowColumns= rowColumns->right;
		while(rowColumns !=NULL){
			addColumnToRow(rowColumns, newNode);
			rowColumns= rowColumns->right;
		}
	}else{
		yyerror("ERROR\n");
	}
}
 vector<int> searchRange(int A[], int n, int target) {
     // Start typing your C/C++ solution below
     // DO NOT write int main() function
     vector<int> range(2);
     range[0] = searchLeft(A, 0, n-1, target);
     range[1] = searchRight(A, 0, n-1, target);
     return range;
 }
Пример #3
0
list* searchObject(list* typesList, char* objectName){
	if(typesList!=NULL){
		list* tempList= typesList->down;
		list* temp;
		while(tempList!=NULL){
			temp= searchRight(objectName, tempList);
			if(temp!=NULL)
				return tempList;
			tempList= tempList->down;
		}
	}
	return NULL;
}
int MinimumSizeSubarraySum::minSubArrayLen_BinarySearch(int s, vector<int> &nums) {
    if (nums.empty()) return 0;

    int n = nums.size(), ret = n + 1;
    vector<int> sums(n + 1, 0);

    for (int i = 1; i <= n; i++)
        sums[i] = sums[i - 1] + nums[i - 1];

    for (int i = 0; i <= n; i++) {
        int r = searchRight(i + 1, n, sums[i] + s, sums);
        if (r == n + 1) break;
        ret = min(ret, r - i);
    }

    return ret == n + 1 ? 0 : ret;
}
Пример #5
0
 bool contains(const kmer_t & A) {
   auto in_bf = bf_.lookup(A);
   // if A is not in BF -- return right away
   if (!in_bf) {
     return in_bf;
   }
   extended_check++;
   auto left_in_bf = searchLeft(A, extend_len, k, &bf_);
   if (in_bf && left_in_bf) {
     return true;
   }
   // here, even if kmer A is in the BF, may return false b.c. its extension is not in BF
   extended_check++;
   auto right_in_bf = searchRight(A, extend_len, k, &bf_);
   if (in_bf && right_in_bf) {
     return true;
   }
   return false;
 }
Пример #6
0
 bool contains(const kmer_t & kmer){
   if(!bf_.lookup(kmer)){
     return false;
   }
   extended_check++;
   bool containsLeft = searchLeft(kmer,extend_len,k,&bf_);
   bool containsRight = searchRight(kmer,extend_len,k,&bf_);
   if(containsLeft && containsRight){
     return true;
   }
   if(containsLeft || containsRight){
     //assumes read length > k+extend_len
     edge_check++;
     if(edge_kmers.find(kmer)!=edge_kmers.end()){
       edge_pass++;
       return true;
     }
   }
   return false;
 }
Пример #7
0
list* addColumnToRow(list* column, list* row){
	list* rowDown= row->down;
	if(rowDown==NULL){
		rowDown= (list*)malloc(sizeof(list));
		row->down= rowDown;
	}

	list* searchNode= searchRight(column->nodeName, rowDown);
	if(searchNode==NULL){
		list* newNode= createListNode(column->nodeName);
		copyAttributes(newNode, column->attrList);
		if(column->text!=NULL && column->down!=NULL){
			yyerror("ERROR\n");
		}
		else if(column->text!=NULL)
			newNode->text= strdup(column->text);
		
		addRight(newNode, rowDown);
		if(column->down!=NULL)
			addTableToColumn(column->down, newNode);
	}else
		yyerror("ERROR\n");
}