コード例 #1
0
ファイル: balance.cpp プロジェクト: GalinaSazonova/1semester
bool bracketBalance(Stack *stack, char *line)
{
	for (int i = 0; line[i] != '\0'; i++)
	{
		char symbol = line[i];
		if (symbol != '('  && symbol != '{' && symbol != '[' && symbol != ']'  && symbol != '}' &&  symbol != ')' )
		{
			continue;
		}
		if (symbol == '('  || symbol == '{' ||  symbol == '[' )
		{
			push(stack, symbol);
			continue;
		}
		if (!notEmpty(stack))
		{
			return false;
		}
		if ((symbol == ')') && (top(stack) == '(') || (symbol == ']') && (top(stack) == '[') || (symbol == '}') && (top(stack) == '{'))
		{
			pop(stack);
			continue;
		}
		else
		{
			return false;
		}
	}
	return !notEmpty(stack);
}
コード例 #2
0
ファイル: validate.cpp プロジェクト: G-Node/nix
Result validate(const File &file) {
    return validator({
        could(file, &File::isOpen, notFalse(), {
            must(file, &File::createdAt, notFalse(), "date is not set!"),
            should(file, &File::version, notEmpty(), "version is not set!"),
            should(file, &File::format, notEmpty(), "format is not set!"),
            should(file, &File::location, notEmpty(), "location is not set!") })
    });
}
コード例 #3
0
ファイル: validate.cpp プロジェクト: G-Node/nix
Result validate_named_entity(const base::NamedEntity<T> &named_entity) {
    Result result_base = validate_entity<T>(named_entity);
    Result result = validator({
        must(named_entity, &base::NamedEntity<T>::name, notEmpty(), "no name set!"),
        must(named_entity, &base::NamedEntity<T>::type, notEmpty(), "no type set!")
    });

    return result.concat(result_base);
}
コード例 #4
0
ファイル: history.cpp プロジェクト: dos1/Gogomoku
Field History::takeFromHistory(){
    if(notEmpty()==FALSE){
        throw new EmptyHistory();
    }
	return hist.takeLast();

}
コード例 #5
0
ファイル: validate.cpp プロジェクト: G-Node/nix
Result validate(const DataArray &data_array) {
    Result result_base = validate_entity_with_sources(data_array);
    Result result = validator({
        must(data_array, &DataArray::dataType, notEqual<DataType>(DataType::Nothing), "data type is not set!"),
        must(data_array, &DataArray::dimensionCount, isEqual<size_t>(data_array.dataExtent().size()), "data dimensionality does not match number of defined dimensions!", {
            could(data_array, &DataArray::dimensions, notEmpty(), {
                must(data_array, &DataArray::dimensions, dimTicksMatchData(data_array), "in some of the Range dimensions the number of ticks differs from the number of data entries along the corresponding data dimension!"),
                must(data_array, &DataArray::dimensions, dimLabelsMatchData(data_array), "in some of the Set dimensions the number of labels differs from the number of data entries along the corresponding data dimension!") }) }),
        could(data_array, &DataArray::unit, notFalse(), {
            should(data_array, &DataArray::unit, isValidUnit(), "Unit is not SI or composite of SI units.") }),
        could(data_array, &DataArray::polynomCoefficients, notEmpty(), {
            should(data_array, &DataArray::expansionOrigin, notFalse(), "polynomial coefficients for calibration are set, but expansion origin is missing!") }),
        could(data_array, &DataArray::expansionOrigin, notFalse(), {
            should(data_array, &DataArray::polynomCoefficients, notEmpty(), "expansion origin for calibration is set, but polynomial coefficients are missing!") })
    });

    return result.concat(result_base);
}
コード例 #6
0
ファイル: validate.cpp プロジェクト: G-Node/nix
Result validate(const RangeDimension &range_dim) {
    return validator({
        must(range_dim, &RangeDimension::index, notSmaller(1), "index is not set to valid value (size_t > 0)!"),
        must(range_dim, &RangeDimension::ticks, notEmpty(), "ticks are not set!"),
        must(range_dim, &RangeDimension::dimensionType, isEqual<DimensionType>(DimensionType::Range), "dimension type is not correct!"),
        could(range_dim, &RangeDimension::unit, notFalse(), {
            must(range_dim, &RangeDimension::unit, isAtomicUnit(), "Unit is set but not an atomic SI. Note: So far composite units are not supported!") }),
        must(range_dim, &RangeDimension::ticks, isSorted(), "Ticks are not sorted!")
    });
}
コード例 #7
0
ファイル: validate.cpp プロジェクト: G-Node/nix
Result validate(const MultiTag &multi_tag) {
    Result result_base = validate_entity_with_sources(multi_tag);
    Result result = validator({
        must(multi_tag, &MultiTag::positions, notFalse(), "positions are not set!"),
        // check units for validity
        could(multi_tag, &MultiTag::units, notEmpty(), {
            must(multi_tag, &MultiTag::units, isValidUnit(), "Some of the units in tag are invalid: not an atomic SI. Note: So far composite SI units are not supported!"),
            must(multi_tag, &MultiTag::references, tagUnitsMatchRefsUnits(multi_tag.units()), "Some of the referenced DataArrays' dimensions have units that are not convertible to the units set in tag. Note: So far composite SI units are not supported!")}),
        // check positions & extents
        could(multi_tag, &MultiTag::extents, notFalse(), {
            must(multi_tag, &MultiTag::positions, extentsMatchPositions(multi_tag.extents()), "Number of entries in positions and extents do not match!") }),
        could(multi_tag, &MultiTag::references, notEmpty(), {
            could(multi_tag, &MultiTag::extents, notFalse(), {
                must(multi_tag, &MultiTag::extents, extentsMatchRefs(multi_tag.references()), "number of entries (in 2nd dim) in extents does not match number of dimensions in all referenced DataArrays!") }),
            must(multi_tag, &MultiTag::positions, positionsMatchRefs(multi_tag.references()), "number of entries (in 2nd dim) in positions does not match number of dimensions in all referenced DataArrays!") })
    });

    return result.concat(result_base);
}
コード例 #8
0
ファイル: prime.c プロジェクト: Oedipus/OS-Projects
//inserts node to the head of a list
void insert (LIST * lp,int n ) {
	NODE *p=(NODE *)malloc(sizeof(NODE*));
    p->data=n;
    if(!notEmpty(*lp)){
        lp->first=p;
        return;
    }
    p->next=lp->first;
    lp->first=p;
    return;
}
コード例 #9
0
ファイル: validate.cpp プロジェクト: G-Node/nix
Result validate(const Tag &tag) {
    Result result_base = validate_entity_with_sources(tag);
    Result result = validator({
        must(tag, &Tag::position, notEmpty(), "position is not set!"),
        could(tag, &Tag::references, notEmpty(), {
            must(tag, &Tag::position, positionsMatchRefs(tag.references()),
                "number of entries in position does not match number of dimensions in all referenced DataArrays!"),
            could(tag, &Tag::extent, notEmpty(), {
                must(tag, &Tag::position, extentsMatchPositions(tag.extent()), "Number of entries in position and extent do not match!"),
                must(tag, &Tag::extent, extentsMatchRefs(tag.references()),
                    "number of entries in extent does not match number of dimensions in all referenced DataArrays!") })
        }),
        // check units for validity
        could(tag, &Tag::units, notEmpty(), {
            must(tag, &Tag::units, isValidUnit(), "Unit is invalid: not an atomic SI. Note: So far composite units are not supported!"),
            must(tag, &Tag::references, tagRefsHaveUnits(tag.units()), "Some of the referenced DataArrays' dimensions don't have units where the tag has. Make sure that all references have the same number of dimensions as the tag has units and that each dimension has a unit set."),
                must(tag, &Tag::references, tagUnitsMatchRefsUnits(tag.units()), "Some of the referenced DataArrays' dimensions have units that are not convertible to the units set in tag. Note: So far composite SI units are not supported!")}),
    });

    return result.concat(result_base);
}
コード例 #10
0
ファイル: validate.cpp プロジェクト: G-Node/nix
Result validate(const Property &property) {
    Result result_base = validate_entity(property);
    Result result = validator({
        must(property, &Property::name, notEmpty(), "name is not set!"),
        could(property, &Property::valueCount, notFalse(), {
            should(property, &Property::unit, notFalse(), "values are set, but unit is missing!") }),
        could(property, &Property::unit, notFalse(), {
            must(property, &Property::unit, isValidUnit(), "Unit is not SI or composite of SI units.") })
        // TODO: dataType to be tested too?
    });

    return result.concat(result_base);
}
コード例 #11
0
ファイル: prime.c プロジェクト: Oedipus/OS-Projects
static int *removeMultiples(NODE *arg){
    NODE *p = (NODE *)arg;
    NODE*q=NULL;
    int n=p->data;
    if (!notEmpty(*myList)) return;
    //check next value and eliminate if smaller than sqrt(N)
    arg=arg->next;
    if(arg->data<=root){
      c++;
      pthread_create(&(threads[c]),NULL,removeMultiples,(void *)arg);  
    }
    //critical section, deletion of multiples of a prime
    pthread_mutex_lock(&listLock);
    while (p) {
        q=p;
        p=p->next;
	if(!p)break;
        if (p->data%n==0) {
            q->next=p->next;
            free (p);
        }
    } //end of critical section
    pthread_mutex_unlock(&listLock); //release the lock
}//end of thread function
コード例 #12
0
ファイル: validate.cpp プロジェクト: G-Node/nix
Result validate_entity(const base::Entity<T> &entity) {
    return validator({
        must(entity, &base::Entity<T>::id, notEmpty(), "id is not set!"),
        must(entity, &base::Entity<T>::createdAt, notFalse(), "date is not set!")
    });
}