当前位置: 首页>>代码示例>>C++>>正文


C++ check_index函数代码示例

本文整理汇总了C++中check_index函数的典型用法代码示例。如果您正苦于以下问题:C++ check_index函数的具体用法?C++ check_index怎么用?C++ check_index使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了check_index函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SYS_read_from_string_internal

// ### %read-from-string string eof-error-p eof-value start end preserve-whitespace
// => object, position
Value SYS_read_from_string_internal(Value arg1, Value arg2, Value arg3,
                                    Value arg4, Value arg5, Value arg6)
{
  AbstractString * string = check_string(arg1);
  bool eof_error_p = (arg2 != NIL);
  bool preserve_whitespace = (arg6 != NIL);
  INDEX start;
  if (arg4 != NIL)
    start = check_index(arg4);
  else
    start = 0;
  INDEX end;
  if (arg5 != NIL)
    end = check_index(arg5);
  else
    end = string->length();
  StringInputStream * in = new StringInputStream(string, start, end);
  Thread * const thread = current_thread();
  Value result;
  Readtable * rt = check_readtable(thread->symbol_value(S_current_readtable));
  if (preserve_whitespace)
    result = stream_read_preserving_whitespace(make_value(in), eof_error_p, arg3, false, thread, rt);
  else
    result = stream_read(make_value(in), eof_error_p, arg3, false, thread, rt);
  return thread->set_values(result, make_fixnum(in->offset()));
}
开发者ID:bsmr-common-lisp,项目名称:xcl,代码行数:28,代码来源:StringInputStream.cpp

示例2: check_index

void unsigned_union_find::make_union(size_type j, size_type k)
{
  check_index(j);
  check_index(k);

  // make sure j, k are roots
  j=find(j);
  k=find(k);

  if(j==k)
    return; // already in same set

  // weight it

  if(nodes[j].count < nodes[k].count)  // j is the smaller set
  {
    nodes[k].count+=nodes[j].count;  // so k becomes parent to j
    nodes[j].parent=k;
    nodes[j].count=0;
  }
  else // j is NOT the smaller
  {
    nodes[j].count+=nodes[k].count;  // so j becomes parent to k
    nodes[k].parent=j;
    nodes[k].count=0;
  }
}
开发者ID:danpoe,项目名称:cbmc,代码行数:27,代码来源:union_find.cpp

示例3: SYS_fasl_sharp_left_paren

// ### fasl-sharp-left-paren stream sub-char numarg => value
Value SYS_fasl_sharp_left_paren(Value streamarg, Value subchar, Value numarg)
{
  Thread * thread = current_thread();
  if (thread->symbol_value(S_read_suppress) != NIL)
    {
      stream_read_list(streamarg, true, thread, FASL_READTABLE);
      return NIL;
    }
  if (numarg != NIL && thread->symbol_value(S_backquote_count) == FIXNUM_ZERO)
    return stream_read_vector(streamarg, check_index(numarg), thread, FASL_READTABLE);
  Value list = stream_read_list(streamarg, true, thread, FASL_READTABLE);
  if (thread->symbol_value(S_backquote_count) == FIXNUM_ZERO)
    {
      if (numarg != NIL)
        {
          INDEX len = check_index(numarg);
          SimpleVector * vector = new_simple_vector(len);
          for (INDEX i = 0; i < len; i++)
            {
              vector->inline_xaset(i, car(list));
              if (cdr(list) != NIL)
                list = xcdr(list);
            }
          return make_value(vector);
        }
      return make_value(new_simple_vector(list));
    }
  return make_cons(thread->symbol_value(S_backquote_vector_flag), list);
}
开发者ID:bsmr-common-lisp,项目名称:xcl,代码行数:30,代码来源:FaslReadtable.cpp

示例4: check_index

        void Matrix::do_jacobi_rotation(int p, int q, /*out*/ Matrix & current_transformation)
        {
            check_index(p);
            check_index(q);
            
            // check for invalid rotation
            if(p == q)
            {
                Logger::warning("incorrect jacobi rotation: `p` and `q` must be different indices", __FILE__, __LINE__);
                return;
            }
            
            // if element is already zeroed
            if(0 == get_at(p,q))
                return;

            // r is the remaining index: not p and not q
            int r = 3 - p - q;

            // theta is cotangent of Real rotation angle
            Real theta = (get_at(q,q) - get_at(p,p))/get_at(p,q)/2;
            // t is sin/cos of rotation angle
            // it is determined from equation t^2 + 2*t*theta - 1 = 0,
            // which implies from definition of theta as (cos^2 - sin^2)/(2*sin*cos)
            Real t = (0 != theta) ? sign(theta)/(abs(theta) + sqrt(theta*theta + 1)) : 1;
            Real cosine = 1/sqrt(t*t + 1);
            Real sine = t*cosine;
            // tau is tangent of half of rotation angle
            Real tau = sine/(1 + cosine);

            add_at(p, p, - t*get_at(p,q));
            add_at(q, q, + t*get_at(p,q));
            
            // correction to element at (r,p)
            Real rp_correction = - sine*(get_at(r,q) + tau*get_at(r,p));
            // correction to element at (r,q)
            Real rq_correction = + sine*(get_at(r,p) - tau*get_at(r,q));
            add_at(r, p, rp_correction);
            add_at(p, r, rp_correction);
            add_at(r, q, rq_correction);
            add_at(q, r, rq_correction);
            set_at(p, q, 0);
            set_at(q, p, 0);

            // construct matrix of applied jacobi rotation
            Matrix rotation = Matrix::IDENTITY;
            rotation.set_at(p, p, cosine);
            rotation.set_at(q, q, cosine);
            rotation.set_at(p, q, sine);
            rotation.set_at(q, p, - sine);
            current_transformation = current_transformation*rotation;
        }
开发者ID:NIA,项目名称:crash-and-squeeze,代码行数:52,代码来源:matrix.cpp

示例5: if

T* dag<T>::get_arg(std::stringstream& in, const int i) {

    char a;
    in >> a;

    int offset;
    in >> offset;

    T* arg = 0;
    int ub = 0;

    if (a == 'n') {
        ub  = num_of_nums;
        arg = num;
    }
    else if (a == 'v') {
        ub  = num_of_vars;
        arg = var;
    }
    else if (a == 't') {
        ub  = i;
        arg = tmp;
    }
    else {
        error("incorrect argument");
    }

    check_index(offset, ub);

    arg += offset;

    return arg;
}
开发者ID:baharev,项目名称:asol,代码行数:33,代码来源:dag.hpp

示例6: _set_page_image

/*
 * call-seq:
 *   set_page_image(pos,iid) -> self
 *
 * sets the image idx of the given page.
 * ===Arguments
 * * pos is a Integer
 * * iid Integer index of the image in the image_list
 *
 * ===Return value
 * self
 * === Exceptions
 * [IndexError]
 * * pos is greater than the count of pages
 * * iid is greater than the count of images in the image_list
*/
DLL_LOCAL VALUE _set_page_image(VALUE self,VALUE idx,VALUE iid)
{
	rb_check_frozen(self);
	int cidx(NUM2INT(idx));

	if(check_index(cidx,_self->GetPageCount()))
	{
		int ciid(NUM2INT(iid));
		wxImageList *imglist = _self->GetImageList();
		if(imglist && check_index(ciid,imglist->GetImageCount()))
		{
			_self->SetPageImage(cidx,ciid);
		}
	}
	return self;
}
开发者ID:rinkevichjm,项目名称:rwx,代码行数:32,代码来源:wxBookCtrl.cpp

示例7: assert

	const BoundingBox &RStarTreeNode::get_element_bounding_box(
		const Uint32 index) const
	{
		assert(check_index(index));

		return m_elements[index]->get_bounding_box();
	}
开发者ID:BackupTheBerlios,项目名称:elc,代码行数:7,代码来源:rstartreenode.cpp

示例8: G_fatal_error

/*!
  \brief Get number of feature types for given layer index 
  
  G_fatal_error() is called when index not found.
  
  \param Map pointer to Map_info structure
  \param field_index layer index
  
  \return number of feature types
  \return -1 on error
 */
int Vect_cidx_get_num_types_by_index(const struct Map_info *Map, int field_index)
{
    check_status(Map);
    check_index(Map, field_index);

    return Map->plus.cidx[field_index].n_types;
}
开发者ID:caomw,项目名称:grass,代码行数:18,代码来源:cindex.c

示例9: print_constant

void BytecodePrinter::print_constant(int i, outputStream* st) {
  int orig_i = i;
  if (!check_index(orig_i, i, st))  return;

  ConstantPool* constants = method()->constants();
  constantTag tag = constants->tag_at(i);

  if (tag.is_int()) {
    st->print_cr(" " INT32_FORMAT, constants->int_at(i));
  } else if (tag.is_long()) {
    st->print_cr(" " INT64_FORMAT, constants->long_at(i));
  } else if (tag.is_float()) {
    st->print_cr(" %f", constants->float_at(i));
  } else if (tag.is_double()) {
    st->print_cr(" %f", constants->double_at(i));
  } else if (tag.is_string()) {
    const char* string = constants->string_at_noresolve(i);
    st->print_cr(" %s", string);
  } else if (tag.is_klass()) {
    st->print_cr(" %s", constants->resolved_klass_at(i)->external_name());
  } else if (tag.is_unresolved_klass()) {
    st->print_cr(" <unresolved klass at %d>", i);
  } else if (tag.is_method_type()) {
    int i2 = constants->method_type_index_at(i);
    st->print(" <MethodType> %d", i2);
    print_symbol(constants->symbol_at(i2), st);
  } else if (tag.is_method_handle()) {
    int kind = constants->method_handle_ref_kind_at(i);
    int i2 = constants->method_handle_index_at(i);
    st->print(" <MethodHandle of kind %d>", kind, i2);
    print_field_or_method(-i, i2, st);
  } else {
    st->print_cr(" bad tag=%d at %d", tag.value(), i);
  }
}
开发者ID:4T-Shirt,项目名称:OpenJDK-Research,代码行数:35,代码来源:bytecodeTracer.cpp

示例10: check_index

void G1BlockOffsetSharedArray::set_offset_array(size_t index, HeapWord* high, HeapWord* low) {
  check_index(index, "index out of range");
  assert(high >= low, "addresses out of order");
  size_t offset = pointer_delta(high, low);
  check_offset(offset, "offset too large");
  set_offset_array(index, (u_char)offset);
}
开发者ID:benbenolson,项目名称:hotspot_9_mc,代码行数:7,代码来源:g1BlockOffsetTable.inline.hpp

示例11: _getItem

DLL_LOCAL VALUE _getItem(VALUE self,VALUE index)
{
	int cidx = RB_NUM2INT(index);
	if(check_index(cidx,_self->GetItemCount()))
		return wrap(_self->GetItem(cidx));
	return Qnil;
}
开发者ID:Hanmac,项目名称:rwx,代码行数:7,代码来源:wxSizer.cpp

示例12: print_constant

void BytecodePrinter::print_constant(int i, outputStream* st) {
  int orig_i = i;
  if (!check_index(orig_i, false, i, st))  return;

  constantPoolOop constants = method()->constants();
  constantTag tag = constants->tag_at(i);

  if (tag.is_int()) {
    st->print_cr(" " INT32_FORMAT, constants->int_at(i));
  } else if (tag.is_long()) {
    st->print_cr(" " INT64_FORMAT, constants->long_at(i));
  } else if (tag.is_float()) {
    st->print_cr(" %f", constants->float_at(i));
  } else if (tag.is_double()) {
    st->print_cr(" %f", constants->double_at(i));
  } else if (tag.is_string()) {
    oop string = constants->resolved_string_at(i);
    print_oop(string, st);
  } else if (tag.is_unresolved_string()) {
    st->print_cr(" <unresolved string at %d>", i);
  } else if (tag.is_klass()) {
    st->print_cr(" %s", constants->resolved_klass_at(i)->klass_part()->external_name());
  } else if (tag.is_unresolved_klass()) {
    st->print_cr(" <unresolved klass at %d>", i);
  } else if (tag.is_object()) {
    st->print_cr(" " PTR_FORMAT, constants->object_at(i));
  } else {
    st->print_cr(" bad tag=%d at %d", tag.value(), i);
  }
}
开发者ID:tetratec,项目名称:Runescape-Launcher,代码行数:30,代码来源:bytecodeTracer.cpp

示例13: curve_segment

static PyObject *
curve_segment(SKCurveObject * self, PyObject * args)
{
    int idx;
    CurveSegment * segment;
    PyObject * result, *p1, *p2, *p;

    if (!PyArg_ParseTuple(args, "i", &idx))
	return NULL;

    idx = check_index(self, idx, "path.Segment");
    if (idx < 0)
	return NULL;

    segment = self->segments + idx;
    p = SKPoint_FromXY(segment->x, segment->y);
    if (segment->type == CurveBezier)
    {
	p1 = SKPoint_FromXY(segment->x1, segment->y1);
	p2 = SKPoint_FromXY(segment->x2, segment->y2);
	result = Py_BuildValue("i(OO)Oi", segment->type, p1, p2, p,
			       segment->cont);
	Py_XDECREF(p1);
	Py_XDECREF(p2);
    }
    else
    {
	result = Py_BuildValue("i()Oi", segment->type, p, segment->cont);
    }
    Py_XDECREF(p);

    return result;
}
开发者ID:kindlychung,项目名称:sk1,代码行数:33,代码来源:curveobject.c

示例14: Vect_cidx_get_num_cats_by_index

/*!
  \brief Get number of categories for given layer index 
  
  \param Map pointer to Map_info structure
  \param index layer index
  
  \return number of categories
  \return -1 on error
 */
int Vect_cidx_get_num_cats_by_index(const struct Map_info *Map, int index)
{
    check_status(Map);
    check_index(Map, index);

    return Map->plus.cidx[index].n_cats;
}
开发者ID:caomw,项目名称:grass,代码行数:16,代码来源:cindex.c

示例15: CL_digit_char_p

// ### digit-char-p char &optional radix => weight
Value CL_digit_char_p(unsigned int numargs, Value args[])
{
    if (numargs < 1 || numargs > 2)
        return wrong_number_of_arguments(S_digit_char_p, numargs, 1, 2);
    BASE_CHAR c = char_value(args[0]);
    int radix;
    if (numargs == 2)
        radix = check_index(args[1], 2, 36);
    else
        radix = 10;
    if (c >= '0')
    {
        int n = c - '0';
        if (radix <= 10)
            return (n < radix) ? make_fixnum(n) : NIL;
        if (n < 10)
            return make_fixnum(n);
        if (c >= 'A')
        {
            // A-Z
            n -= 7;
            if (n >= 10 && n < radix)
                return make_fixnum(n);
            if (c >= 'a')
            {
                // a-z
                n -= 32;
                if (n >= 10 && n < radix)
                    return make_fixnum(n);
            }
        }
    }
    return NIL;
}
开发者ID:icicle99,项目名称:xcl,代码行数:35,代码来源:characters.cpp


注:本文中的check_index函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。