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


C++ idx函数代码示例

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


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

示例1: QDrag

void Palette::mouseMoveEvent(QMouseEvent* ev)
      {
      if ((currentIdx != -1) && (dragIdx == currentIdx) && (ev->buttons() & Qt::LeftButton)
         && (ev->pos() - dragStartPosition).manhattanLength() > QApplication::startDragDistance()) {
            PaletteCell* cell = cells[currentIdx];
            if (cell && cell->element) {
                  QDrag* drag = new QDrag(this);
                  QMimeData* mimeData = new QMimeData;
                  Element* el  = cell->element;
                  qreal mag    = PALETTE_SPATIUM * extraMag / gscore->spatium();
                  QPointF spos = QPointF(dragStartPosition) / mag;
                  spos        -= QPointF(cells[currentIdx]->x, cells[currentIdx]->y);

                  // DEBUG:
                  spos.setX(0.0);
                  mimeData->setData(mimeSymbolFormat, el->mimeData(spos));
                  drag->setMimeData(mimeData);

                  dragSrcIdx = currentIdx;
                  emit startDragElement(el);
                  if (_readOnly) {
                        drag->start(Qt::CopyAction);
                        }
                  else {
                        /*Qt::DropAction action = */
                        drag->start(Qt::DropActions(Qt::CopyAction | Qt::MoveAction));
                        }
                  }
            }
      else {
            QRect r;
            if (currentIdx != -1)
                  r = idxRect(currentIdx);
            currentIdx = idx(ev->pos());
            if (currentIdx != -1) {
                  if (cells[currentIdx] == 0)
                        currentIdx = -1;
                  else
                        r |= idxRect(currentIdx);
                  }
            update(r);
            }
      }
开发者ID:NalinG,项目名称:MuseScore,代码行数:43,代码来源:palette.cpp

示例2: CreateMat

MatHandler CreateMat(int cols, int rows, TYPE *nums){
	matrix_t *m = (matrix_t *)calloc(1, sizeof(matrix_t));
	if (m){
		assert(cols > 0 && rows > 0);
		m->cols = cols; m->rows = rows;
		m->data = (TYPE *)calloc(cols*rows, sizeof(TYPE));
		if (m->data){
			if (nums){
				for (int i = 0; i < cols; ++i){
					for (int j = 0; j < rows; ++j){
						m->data[idx(i, cols, j)] = *(nums + j*cols + i);
					}
				}
			}
			return (MatHandler *)m;
		}
	}
	return NULL;
}
开发者ID:IanTatiana,项目名称:Computer-Graphics,代码行数:19,代码来源:Matrix.cpp

示例3: idx

int IndexedTriangleIO::insertFlattenedVertexVTN(const int v, const int t, const  int n)
{
  Vec3i idx(v,t,n);
  std::map<Vec3i,size_t>::iterator it = mIndicesCache.find(idx);

  //vertex does not exist
  if(it==mIndicesCache.end())
  {
    it = (mIndicesCache.insert(std::make_pair(idx,mVertexPosition.size()))).first;
    mVertexPosition.push_back(mVertexPositionCache[v-1]);

    // copy / duplicate texcoords and normals if appropriate
    if(t >= 0)
      mVertexTextureCoordinate.push_back(mVertexTextureCoordinateCache[t-1]);
    if(n >= 0)
      mVertexNormal.push_back(mVertexNormalCache[n-1]);
  }
  return int(it->second);
}
开发者ID:HerrR,项目名称:Datorgrafik-Visualisering,代码行数:19,代码来源:IndexedTriangleIO.cpp

示例4: offset

STD1::uint32_t Document::writeNameMap( std::FILE* out )
{
    STD1::uint32_t offset( 0 );
    if( !isInf() && !nameMap.empty() ) {
        offset = std::ftell( out );
        ConstNameMapIter itr;
        for( itr = nameMap.begin(); itr != nameMap.end(); ++itr ) {
            STD1::uint16_t index( itr->first->index() );
            if( std::fwrite( &index, sizeof( STD1::uint16_t ), 1, out ) != 1 )
                throw FatalError( ERR_WRITE );
        }
        for( itr = nameMap.begin(); itr != nameMap.end(); ++itr ) {
            STD1::uint16_t idx( itr->second.index() );
            if( std::fwrite( &idx, sizeof( STD1::uint16_t ), 1, out ) != 1 )
                throw FatalError( ERR_WRITE );
        }
    }
    return offset;
}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:19,代码来源:document.cpp

示例5: pyGeometrySpan_setIndices

static int pyGeometrySpan_setIndices(pyGeometrySpan* self, PyObject* value, void*) {
    if (value == NULL || !PySequence_Check(value)) {
        PyErr_SetString(PyExc_TypeError, "indices should be a sequence of unsigned shorts");
        return -1;
    }
    size_t count = PySequence_Size(value);
    for (size_t i = 0; i < count; ++i) {
        if (!PyInt_Check(PySequence_Fast_GET_ITEM(value, i))) {
            PyErr_SetString(PyExc_TypeError, "indices should be a sequence of unsigned shorts");
            return -1;
        }
    }

    std::vector<unsigned short> idx(PySequence_Size(value));
    for (size_t i = 0; i < idx.size(); ++i)
        idx[i] = PyInt_AsLong(PySequence_Fast_GET_ITEM(value, i));
    self->fThis->setIndices(idx);
    return 0;
}
开发者ID:GPNMilano,项目名称:libhsplasma,代码行数:19,代码来源:pyGeometrySpan.cpp

示例6: update_map_pos

void update_map_pos()
{
    // z (blender x) 100m
    // x (blender y) 100m

    float ratio = (float) screen_map_len / 100;
    float half = screen_map_len / 2;

    map_pos_u = mypos.x * ratio + half;
    map_pos_v =-mypos.z * ratio + half;

    float mu = (float) map_len_u / screen_map_len;
    float mv = (float) map_len_v / screen_map_len;

    iu = map_pos_u * mu;
    iv = map_pos_v * mv;

	altura_terreno = idx();
}
开发者ID:tfcporciuncula,项目名称:walker,代码行数:19,代码来源:event.c

示例7: SparseMatrix

SparseMatrix* MainWindow::buildModel(const QImage &img)
{
    SparseMatrix *ret = new SparseMatrix(5,this); //Dims: 0=north 1=south 2=east 3=west 4=pos
    for(int row = 0; row<img.height(); row++)
    {
        for(int col = 0; col<img.width(); col++)
        {
            Vector_t idx(5);
            idx[0] = (row == 0) ? 5 : QColor(img.pixel(col,row-1)).lightness()&0xFF;
            idx[1] = (row+1 == img.height()) ? 5 : QColor(img.pixel(col,row+1)).lightness()&0xFF;
            idx[2] = (col == 0) ? 5 : QColor(img.pixel(col-1,row)).lightness()&0xFF;
            idx[3] = (col+1 == img.width()) ? 5 : QColor(img.pixel(col+1,row)).lightness()&0xFF;
            idx[4] = QColor(img.pixel(col,row)).lightness()&0xFF;
            if(!idx.contains(5)) //ignore edge pixels
                ret->inc(idx);
        }
    }
    return ret;
}
开发者ID:Team-2502,项目名称:CodeTools,代码行数:19,代码来源:mainwindow.cpp

示例8: CreateMinorMat

int CreateMinorMat(MatHandler mat, int icol, int jrow, MatHandler *ans){ /*	Создает минор только n-1-ого порядка*/
	matrix_t *a, *m = (matrix_t *)mat;
	assert(m->cols > 1 && m->rows > 1);
	a = (matrix_t *)(*ans) = (matrix_t *)CreateMat(m->cols - 1, m->rows - 1, NULL);
	if (!a) return M_ERR_ALLOC;
	a->cols = m->cols - 1;
	a->rows = m->rows - 1;
	int id = 0;
	for (int i = 0; i < m->cols; ++i){
		if (i == icol) continue;
		for (int j = 0; j < m->rows; ++j){
			if (j == jrow) continue;
			int r = idx(i, m->cols, j);
			a->data[id] = m->data[r];
			++id;
		}
	}
	return M_OK;
}
开发者ID:IanTatiana,项目名称:Computer-Graphics,代码行数:19,代码来源:Matrix.cpp

示例9: main

int main(int narg, char* arg[]) {
  Kokkos::initialize (narg, arg);

  int size = 1000000;

  idx_type idx("Idx",size,64);
  idx_type_host h_idx = Kokkos::create_mirror_view (idx);

  view_type dest ("Dest", size);
  view_type src ("Src", size);

  srand(134231);

  for (int i = 0; i < size; i++) {
    for (view_type::size_type j = 0; j < h_idx.dimension_1 (); ++j) {
      h_idx(i,j) = (size + i + (rand () % 500 - 250)) % size;
    }
  }

  // Deep copy the initial data to the device
  Kokkos::deep_copy(idx,h_idx);
  // Run the first kernel to warmup caches
  Kokkos::parallel_for(size,localsum<view_type,view_type_rnd>(idx,dest,src));
  Kokkos::fence();

  // Run the localsum functor using the RandomAccess trait. On CPUs there should
  // not be any different in performance to not using the RandomAccess trait.
  // On GPUs where can be a dramatic difference
  Kokkos::Impl::Timer time1;
  Kokkos::parallel_for(size,localsum<view_type,view_type_rnd>(idx,dest,src));
  Kokkos::fence();
  double sec1 = time1.seconds();

  Kokkos::Impl::Timer time2;
  Kokkos::parallel_for(size,localsum<view_type,view_type>(idx,dest,src));
  Kokkos::fence();
  double sec2 = time2.seconds();

  printf("Time with Trait RandomAccess: %f with Plain: %f \n",sec1,sec2);

  Kokkos::finalize();
}
开发者ID:BrianMoths,项目名称:lammps,代码行数:42,代码来源:memory_traits.cpp

示例10: version

local_mirror_t<Object>::local_mirror_t(fh_map_t *map_, Object b, 
				       boost::uint32_t v, const std::string &migr_svc) : 
    version(v), snapshot_marker(v), blob(b), fh_map(map_), blob_size(b->get_size(v)), 
    page_size(b->get_page_size()), chunk_map(blob_size / page_size, CHUNK_UNTOUCHED), 
    written_map(blob_size / page_size, false),
    async_io_thread(boost::bind(&local_mirror_t<Object>::async_io_exec, this)),
    migration_thread(boost::bind(&migration_wrapper::migr_exec, blob.get(),
				 (migration_wrapper::updater_t)
				 boost::bind(&local_mirror_t<Object>::schedule_chunk, this, _1),
				 (migration_wrapper::updater_t)
				 boost::bind(&local_mirror_t<Object>::cancel_chunk, this, _1),
				 boost::cref(migr_svc))), migr_flag(false)
{

    std::stringstream ss;
    ss << "/tmp/blob-mirror-" << b->get_id() << "-" << version;
    local_name = ss.str();
    
    if ((fd = open(local_name.c_str(), 
		   O_RDWR | O_CREAT | O_NOATIME, 0666)) == -1)
	throw std::runtime_error("could not open temporary file: " + local_name);
    flock lock;
    lock.l_type = F_WRLCK; lock.l_whence = SEEK_SET;
    lock.l_start = 0; lock.l_len = blob_size;
    if (fcntl(fd, F_SETLK, &lock) == -1) {
	close(fd);
	throw std::runtime_error("could not lock temporary file: " + local_name);
    }
    if (lseek(fd, 0, SEEK_END) != (off_t)blob_size) {
	lseek(fd, blob_size - 1, SEEK_SET);
	if (::write(fd, &blob_size, 1) != 1) {
	    close(fd);
	    throw std::runtime_error("could not adjust temporary file: " + local_name);
	}
    }

    std::ifstream idx((local_name + ".idx").c_str(), 
		      std::ios_base::in | std::ios_base::binary);
    if (idx.good()) {
	boost::archive::binary_iarchive ar(idx);
	ar >> chunk_map >> written_map;
    }
开发者ID:lizhe1240,项目名称:blobseer,代码行数:42,代码来源:local_mirror.hpp

示例11: chunk_visitor

static bool chunk_visitor(
  const RBTree_Node *node,
  RBTree_Direction dir,
  void *visitor_arg
)
{
  rtems_rbheap_chunk *chunk = rtems_rbheap_chunk_of_node(node);
  chunk_visitor_context *context = visitor_arg;

  rtems_test_assert(context->index_current != context->index_end);
  rtems_test_assert(context->free_current != context->free_end);

  rtems_test_assert(idx(chunk) == *context->index_current);
  rtems_test_assert(rtems_rbheap_is_chunk_free(chunk) == *context->free_current);

  ++context->index_current;
  ++context->free_current;

  return false;
}
开发者ID:chch1028,项目名称:rtems,代码行数:20,代码来源:init.c

示例12: sort_indexes

vector<int> sort_indexes(const vector<double> &v) {

  // initialize original index locations
  vector<int> idx(v.size());
  for (int i = 0; i != idx.size(); ++i) idx[i] = i;

  // sort indexes based on comparing values in v
	//I can't use std::sort because c++ is super gay
	int temp;
	for(int j=idx.size();j>0;j--){
		for(int i=0;i<j-1;i++){
			if(v[idx[i]]>v[idx[i+1]]){
				 temp=idx[i];
				 idx[i]=idx[i+1];
				 idx[i+1]=temp;
			}
		}
	}
  return idx;
}
开发者ID:scottgeraedts,项目名称:myClibrary,代码行数:20,代码来源:utils.cpp

示例13: dat

Thesaurus::Thesaurus(agi::fs::path const& dat_path, agi::fs::path const& idx_path)
: dat(io::Open(dat_path))
{
	std::unique_ptr<std::ifstream> idx(io::Open(idx_path));

	std::string encoding_name;
	getline(*idx, encoding_name);
	std::string unused_entry_count;
	getline(*idx, unused_entry_count);

	// Read the list of words and file offsets for those words
	for (line_iterator<std::string> iter(*idx, encoding_name), end; iter != end; ++iter) {
		std::vector<std::string> chunks;
		boost::split(chunks, *iter, _1 == '|');
		if (chunks.size() == 2)
			offsets[chunks[0]] = atoi(chunks[1].c_str());
	}

	conv.reset(new charset::IconvWrapper(encoding_name.c_str(), "utf-8"));
}
开发者ID:seawaveT,项目名称:Aegisub,代码行数:20,代码来源:thesaurus.cpp

示例14: dat

Thesaurus::Thesaurus(agi::fs::path const& dat_path, agi::fs::path const& idx_path)
: dat(make_unique<read_file_mapping>(dat_path))
{
	read_file_mapping idx_file(idx_path);
	boost::interprocess::ibufferstream idx(idx_file.read(), static_cast<size_t>(idx_file.size()));

	std::string encoding_name;
	getline(idx, encoding_name);
	std::string unused_entry_count;
	getline(idx, unused_entry_count);

	conv = make_unique<charset::IconvWrapper>(encoding_name.c_str(), "utf-8");

	// Read the list of words and file offsets for those words
	for (auto const& line : line_iterator<std::string>(idx, encoding_name)) {
		auto pos = line.find('|');
		if (pos != line.npos && line.find('|', pos + 1) == line.npos)
			offsets[line.substr(0, pos)] = static_cast<size_t>(atoi(line.c_str() + pos + 1));
	}
}
开发者ID:Phonations,项目名称:Aegisub,代码行数:20,代码来源:thesaurus.cpp

示例15: pcac_correlation_function

double pcac_correlation_function(int t)
{
  complex double C = 0;
  for (int x = 0; x < X1; x ++)
  {
    int index = idx(x, t, X1);
    complex double a = R1[index].s1;
    complex double b = R1[index].s2;
    complex double c = R2[index].s1;
    complex double d = R2[index].s2;
    //C += I * (a * cconj(c) - c * cconj(a) + b * cconj(d) - d * cconj(b));
    C += -cimag(a * cconj(c)) - cimag(b * cconj(d));
    //C += -cimag(c);
    //C += -cimag(a * cconj(b)) - cimag(c * cconj(d));
  }
  C *= 2;
  if (fabs(cimag(C)) > 1e-6)
    printf("\nImaginary part of PCAC correlation function detected!\n");
  return fabs(C);
}
开发者ID:MrMage,项目名称:schwinger,代码行数:20,代码来源:measurements.c


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