Esempio n. 1
0
    bool operator()(Heap1 const & lhs, Heap2 const & rhs)
    {
        typename Heap1::size_type left_size = lhs.size();
        typename Heap2::size_type right_size = rhs.size();
        if (left_size < right_size)
            return true;

        if (left_size > right_size)
            return false;

        typename Heap1::ordered_iterator it1 = lhs.ordered_begin();
        typename Heap1::ordered_iterator it1_end = lhs.ordered_end();
        typename Heap1::ordered_iterator it2 = rhs.ordered_begin();
        typename Heap1::ordered_iterator it2_end = rhs.ordered_end();
        while (true) {
            if (value_compare(lhs, rhs, *it1, *it2))
                return true;

            if (value_compare(lhs, rhs, *it2, *it1))
                return false;

            ++it1;
            ++it2;

            if (it1 == it1_end && it2 == it2_end)
                return true;

            if (it1 == it1_end || it2 == it2_end)
                return false;
        }
    }
Esempio n. 2
0
    bool operator()(Heap1 const & lhs, Heap2 const & rhs)
    {
        typename Heap1::size_type left_size = lhs.size();
        typename Heap2::size_type right_size = rhs.size();
        if (left_size < right_size)
            return true;

        if (left_size > right_size)
            return false;

        Heap1 lhs_copy(lhs);
        Heap2 rhs_copy(rhs);

        while (true) {
            if (value_compare(lhs_copy, rhs_copy, lhs_copy.top(), rhs_copy.top()))
                return true;

            if (value_compare(lhs_copy, rhs_copy, rhs_copy.top(), lhs_copy.top()))
                return false;

            lhs_copy.pop();
            rhs_copy.pop();

            if (lhs_copy.empty() && rhs_copy.empty())
                return false;
        }
    }
Esempio n. 3
0
int find_insert(Var lst, Var key) {
    /* find_insert(sortedlist,key) => index of first element in sortedlist
       > key.  sortedlist is assumed to bem sorted in increasing order and
       the number returned is anywhere from 1 to length(sortedlist)+1,
       inclusive. */

    /* returns -10 if an E_TYPE occurs */

    Var	compare;
    int	r = lst.v.list[0].v.num, l=1, i;

    while(r >= l) {
        compare = value_compare(var_ref(key), var_ref(lst.v.list[i = ((r + l) / 2)] ) );
        if(compare.type == TYPE_ERR) {
            free_var(compare);
            return -10;
        }
        if(compare.v.num < 0) {
            r = i - 1;
        } else {
            l = i + 1;
        }
    }
    return l;
}
Esempio n. 4
0
static GnmValue *
cb_validate_custom (GnmValueIter const *v_iter, GnmValue const *target)
{
	if (value_compare (v_iter->v, target, FALSE) == IS_EQUAL)
		return VALUE_TERMINATE;
	else
		return NULL;
}
Esempio n. 5
0
 splaytree_impl( bool unique, Iterator b, Iterator e
            , const value_compare &cmp     = value_compare()
            , const value_traits &v_traits = value_traits())
    : tree_type(cmp, v_traits)
 {
    if(unique)
       this->insert_unique(b, e);
    else
       this->insert_equal(b, e);
 }
int
ppl_lexico_compare_linear_expressions (ppl_Linear_Expression_t a,
				       ppl_Linear_Expression_t b)
{
  ppl_dimension_type min_length, length1, length2;
  ppl_dimension_type i;
  ppl_Coefficient_t c;
  int res;
  Value va, vb;

  ppl_Linear_Expression_space_dimension (a, &length1);
  ppl_Linear_Expression_space_dimension (b, &length2);
  ppl_new_Coefficient (&c);
  value_init (va);
  value_init (vb);

  if (length1 < length2)
    min_length = length1;
  else
    min_length = length2;

  for (i = 0; i < min_length; i++)
    {
      ppl_Linear_Expression_coefficient (a, i, c);
      ppl_Coefficient_to_mpz_t (c, va);
      ppl_Linear_Expression_coefficient (b, i, c);
      ppl_Coefficient_to_mpz_t (c, vb);
      res = value_compare (va, vb);

      if (res == 0)
	continue;

      value_clear (va);
      value_clear (vb);
      ppl_delete_Coefficient (c);
      return res;
    }

  value_clear (va);
  value_clear (vb);
  ppl_delete_Coefficient (c);
  return length1 - length2;
}
Esempio n. 7
0
/* The routines to do the sorting */
static int
sort_compare_cells (GnmCell const *ca, GnmCell const *cb,
		    GnmSortClause *clause, gboolean default_locale)
{
	GnmValue *a, *b;
	GnmValueType ta, tb;
	GnmValDiff comp = IS_EQUAL;
	int ans = 0;

	if (!ca)
		a = NULL;
	else
		a = ca->value;
	if (!cb)
		b = NULL;
	else
		b = cb->value;

	ta = VALUE_IS_EMPTY (a) ? VALUE_EMPTY : a->type;
	tb = VALUE_IS_EMPTY (b) ? VALUE_EMPTY : b->type;

	if (ta == VALUE_EMPTY && tb != VALUE_EMPTY) {
		comp = clause->asc ? IS_LESS : IS_GREATER;
	} else if (tb == VALUE_EMPTY && ta != VALUE_EMPTY) {
		comp = clause->asc ? IS_GREATER : IS_LESS;
	} else if (ta == VALUE_ERROR && tb != VALUE_ERROR) {
		comp = IS_GREATER;
	} else if (tb == VALUE_ERROR && ta != VALUE_ERROR) {
		comp = IS_LESS;
	} else {
		comp = default_locale ? value_compare (a, b, clause->cs)
			: value_compare_no_cache (a, b, clause->cs);
	}

	if (comp == IS_LESS) {
		ans = clause->asc ?  1 : -1;
	} else if (comp == IS_GREATER) {
		ans = clause->asc ? -1 :  1;
	}

	return ans;
}
Esempio n. 8
0
hashmap_node_t* hashmap_find(hashmap_t* hashmap,char *string) {
    char* key;
    list_value_t* find=JSON_parse(string);
    key=find->key;
    int create=1;
    hashmap_node_t* result=NULL;
    if(strlen(key)==0) {
        int i;
        for(i=0; i<BUCKET_NUMBER; i++) {
            hashmap_node_t* tmp=hashmap->map[i];
            while (tmp!=NULL) {
                if(create) {
                    result=hashmap_node_create(0, tmp->lt);
                    create=0;
                } else
                    hashmap_node_append_node(result, hashmap_node_create(0, tmp->lt));
                tmp=tmp->next;
            }
        }
        return result;
    } else {
        uint32_t hash=hashmap_hash(key);
        hashmap_node_t* bucket = *hashmap_get_bucket(hashmap, hash);
        if(bucket==NULL)
            return bucket;
        else {
            while(bucket!=NULL) {
                if(bucket->hash==hash && strcmp(key,bucket->lt->key)==0 && value_compare(find, bucket->lt)==0) {
                    if(create) {
                        result=hashmap_node_create(hash, bucket->lt);
                        create=0;
                    } else
                        hashmap_node_append_node(result, hashmap_node_create(hash, bucket->lt));
                }
                bucket=bucket->next;
            }
        }
        return result;
    }
}
Esempio n. 9
0
void hashmap_where(hashmap_node_t** result, char *string) {
    int found=0;
    hashmap_node_t* prev=NULL;
    hashmap_node_t* current=*result;
    list_value_t* tmprec;
    list_value_t* wheres=JSON_parse(string);
    list_value_t* tmpw;
    while (current!=NULL) {
        tmpw=wheres;
        while(tmpw!=NULL) {
            tmprec=current->lt->record;
            while (tmprec!=NULL) {
                if(strcmp(tmpw->key,tmprec->key)==0 && value_compare(tmpw, tmprec) == 0) {
                    found=1;
                }
                tmprec=tmprec->next;
            }
            tmpw=tmpw->next;
        }
        if(!found) {
            if (prev) {
                prev->next=current->next;
                free(current);
                current=prev->next;
            }
            else {
                *result=current->next;
                free(current);
                current=*result;

            }
        } else {
            prev=current;
            current=current->next;
        }
        found=0;
    }
}
Esempio n. 10
0
File: map.hpp Progetto: zoid/ztl
	inline value_compare			value_comp() const	{ return value_compare(m_tree.key_comp()); }
Esempio n. 11
0
 rbtree_impl( bool unique, Iterator b, Iterator e
            , const value_compare &cmp     = value_compare()
            , const value_traits &v_traits = value_traits())
    : tree_type(unique, b, e, cmp, v_traits)
 {}
Esempio n. 12
0
int logclass_filter::compare(const leaf* l) const
{
	const logclass_filter* rhs = dynamic_cast<const logclass_filter*>(l);
	return value_compare(m_class_low, rhs->m_class_low, m_class_high, rhs->m_class_high);
}
Esempio n. 13
0
int logprocessname_filter::compare(const leaf* l) const
{
	const logprocessname_filter* rhs = dynamic_cast<const logprocessname_filter*>(l);
	return value_compare(m_process_name, rhs->m_process_name);
}
Esempio n. 14
0
int logtid_filter::compare(const leaf* l) const
{
	const logtid_filter* rhs = dynamic_cast<const logtid_filter*>(l);
	return value_compare(m_tid, rhs->m_tid);
}
Esempio n. 15
0
int logcontent_filter::compare(const leaf* f) const
{
	const logcontent_filter* rhs = dynamic_cast<const logcontent_filter*>(f);

	return value_compare(m_ignore_case, rhs->m_ignore_case, m_matcher, rhs->m_matcher, m_use_regex, rhs->m_use_regex);
}
Esempio n. 16
0
 //! @copydoc ::boost::intrusive::bstree::bstree(const value_compare &,const value_traits &)
 explicit bs_set_impl( const value_compare &cmp = value_compare()
                  , const value_traits &v_traits = value_traits())
    :  tree_type(cmp, v_traits)
 {}
Esempio n. 17
0
 bs_set_impl( Iterator b, Iterator e
         , const value_compare &cmp = value_compare()
         , const value_traits &v_traits = value_traits())
    : tree_type(true, b, e, cmp, v_traits)
 {}
Esempio n. 18
0
int
list_compare (int * list1)
{
  if (list1)
    value_compare ();
}