Ejemplo n.º 1
0
void GBufferedImage::fillRegion(double x, double y, double width, double height, int rgb) {
    checkIndex("fillRegion", x, y);
    checkIndex("fillRegion", x + width - 1, y + height - 1);
    checkColor("fillRegion", rgb);
    for (int r = (int) y; r < y + height; r++) {
        for (int c = (int) x; c < x + width; c++) {
            m_pixels[r][c] = rgb;
        }
    }
    pp->gbufferedimage_fillRegion(this, x, y, width, height, rgb);
}
Ejemplo n.º 2
0
const unsigned char* SqlStatement::ResultRow::getBlobField(int nField, int& nLen) const {
	require(mpParent->mpVM);
	checkIndex(nField);

	nLen = sqlite3_column_bytes(mpParent->mpVM, nField);
	return (const unsigned char*)sqlite3_column_blob(mpParent->mpVM, nField);
}
Ejemplo n.º 3
0
QModelIndex TreeModel::indexFromItemHelper(const TreeItem *needle,
    TreeItem *parentItem, const QModelIndex &parentIndex) const
{
    checkIndex(parentIndex);
    if (needle == parentItem)
        return parentIndex;
    for (int i = parentItem->rowCount(); --i >= 0; ) {
        TreeItem *childItem = parentItem->child(i);
        QModelIndex childIndex = index(i, 0, parentIndex);
        QModelIndex idx = indexFromItemHelper(needle, childItem, childIndex);
        checkIndex(idx);
        if (idx.isValid())
            return idx;
    }
    return QModelIndex();
}
Ejemplo n.º 4
0
TreeItem *TreeModel::itemFromIndex(const QModelIndex &idx) const
{
    checkIndex(idx);
    TreeItem *item = idx.isValid() ? static_cast<TreeItem*>(idx.internalPointer()) : m_root;
//    CHECK(checkItem(item));
    return item;
}
Ejemplo n.º 5
0
/*
 * Removes the element at the given index from the list,
 * shifting elements left to make room.
 * Throws a string exception if the index is out of bounds.
 */
void ArrayIntList::remove(int index) {
    checkIndex(index, 0, mysize - 1);
    for (int i = index; i < mysize - 1; i++) {
        elements[i] = elements[i + 1];
    }
    mysize--;
}
NOX::Abstract::MultiVector&
LOCA::Extended::MultiVector::setBlock(
				   const LOCA::Extended::MultiVector& source, 
				   const std::vector<int>& index)
{
  // Verify dimensions are consistent
  if (source.numMultiVecRows != numMultiVecRows || 
      source.numScalarRows != numScalarRows) 
    globalData->locaErrorCheck->throwError(
	"LOCA::Extended::MultiVector::setBlock()",
	"Size of supplied multivector is incompatible with this multivector");
  if (static_cast<unsigned int>(source.numColumns) != index.size()) {
   globalData->locaErrorCheck->throwError(
	"LOCA::Extended::MultiVector::setBlock()",
	"Size of supplied index vector is incompatible with this multivector");
  }

  // Set block in each multivec
  for (int i=0; i<numMultiVecRows; i++)
    multiVectorPtrs[i]->setBlock(*(source.multiVectorPtrs[i]),index);

  // Set scalar vectors
  for (unsigned int j=0; j<index.size(); j++) {
    checkIndex("LOCA::Extended::MultiVector::augment()", index[j]);
    for (int i=0; i<numScalarRows; i++)
      (*scalarsPtr)(i,index[j]) = (*source.scalarsPtr)(i,j);
  }

  return *this;
}
double&
LOCA::Extended::MultiVector::getScalar(int i, int j)
{
  checkIndex("LOCA::Extended::MultiVector::getScalar()", i, j);

  return (*scalarsPtr)(i,j);
}
Ejemplo n.º 8
0
	bool Joystick::isOpen(int index)
	{
		if (!checkIndex(index))
			return false;

		return joysticks[index] != 0 ? true : false;
	}
Ejemplo n.º 9
0
Type Stack::getTypeAt(int index) const {
	if (!checkIndex(index)) {
		return kTypeNone;
	}

	switch (lua_type(&_luaState, index)) {
		case LUA_TNONE:
			return kTypeNone;
		case LUA_TNIL:
			return kTypeNil;
		case LUA_TBOOLEAN:
			return kTypeBoolean;
		case LUA_TNUMBER:
			return kTypeNumber;
		case LUA_TSTRING:
			return kTypeString;
		case LUA_TTABLE:
			return kTypeTable;
		case LUA_TFUNCTION:
			return kTypeFunction;
		case LUA_TUSERDATA:
			return kTypeUserType;
		default:
			warning("Unhandled Lua type: %s", lua_typename(&_luaState, index));
			return kTypeNone;
	}
}
Ejemplo n.º 10
0
bool LinkedList::addAll(int index, LinkedList* ll)
{
  checkIndex(index);
  
  void** new_ptr = static_cast<void**>(calloc(reserve_size + ll->reserve_size, PTR_SIZE));


  for ( int i = 0; i < index; ++i )
    {
      new_ptr[i] = ptr[i];
    }

  for ( int i = 0; i < ll->reserve_size; ++i )
    {
      new_ptr[i + index] = ll->ptr[i];
    }

  for ( int i = 0; i < reserve_size - index; ++i )
    {
      new_ptr[i + index + ll->reserve_size] = ptr[i + index];
    }

  free(ptr);

  ptr = new_ptr;

  reserve_size += ll->reserve_size;
}
Ejemplo n.º 11
0
void* LinkedList::remove(int index)
{
  checkIndex(index);
  
  void** new_ptr = static_cast<void**>(calloc(reserve_size - 1, PTR_SIZE));

  for ( int i = 0; i < index; ++i )
    {
      new_ptr[i] = ptr[i];
    }

  void* ret_val = ptr[index];

  for ( int i = 0; i < reserve_size - index; ++i )
    {
      new_ptr[i + index] = ptr[i + index + 1];
    }

  free(ptr);

  ptr = new_ptr;

  --reserve_size;

  return ret_val;
}
Ejemplo n.º 12
0
 inline const AzTree *tree(int tx) const {
   checkIndex(tx, "tree"); 
   if (t[tx] == NULL) {
     return &empty_tree; 
   }
   return t[tx]; 
 }
Ejemplo n.º 13
0
// Return a copy of the column data specified by its index starting at 0
// (use the Column copy-constructor)
Column Statement::getColumn(const int aIndex)
{
    checkRow();
    checkIndex(aIndex);

    // Share the Statement Object handle with the new Column created
    return Column(mStmtPtr, aIndex);
}
Ejemplo n.º 14
0
void LinkedList<T>::pop_front(){
    checkIndex(1);
    ListNode * temp = head->next;
    temp->next->prev = head;
    head->next = temp->next;
    delete temp;
    theSize--;
}
Ejemplo n.º 15
0
void LinkedList<T>::pop_back(){
    checkIndex(theSize);
    ListNode * temp = tail->prev;
    temp->prev->next = tail;
    tail->prev = temp->prev;
    delete temp;
    theSize--;
}
Ejemplo n.º 16
0
	uint32 Matrix::getBytePos(uint16 row, uint16 col) const
	{
		//check the row and column indicies
		checkIndex(row, col);

		//byte position = (row * (bytes per column * # columns)) + (column * bytes per column)
		return (row * (m_valuesTypeSize * m_numColumns)) + (col * m_valuesTypeSize);
	}
Ejemplo n.º 17
0
bool Stack::isUserTypeAt(int index, const Common::UString &type) const {
	if (type.empty()) {
		return getTypeAt(index) == kTypeUserType;
	}

	tolua_Error error;
	return checkIndex(index) && tolua_isusertype(&_luaState, index, type.c_str(), 0, &error) != 0;
}
Ejemplo n.º 18
0
 virtual 
 inline T *tree_u(int tx) const {
   checkIndex(tx, "tree_u"); 
   if (t[tx] == NULL) {
     throw new AzException("AzTrTreeEnsemble::tree_u", "there is no tree"); 
   }
   return t[tx]; 
 }
Ejemplo n.º 19
0
int OnlineSession::normalizeDataSet(int index)
{
    checkIndex(index);

    dataSets[index]->normalize();

    return 0;
}
Ejemplo n.º 20
0
int OnlineSession::dropDataSet(int index)
{
    checkIndex(index);

    dataSets.erase(dataSets.begin() + index);
    groupings.erase(groupings.begin() + index);
    return 0;
}
void LinkedIntList::set(int index, int value) {
    checkLocked("set");
    checkIndex(index, 0, size() - 1);
    ListNode* current = front;
    for (int i = 0; i < index; i++) {
        current = current->next;
    }
    current->data = value;
}
Ejemplo n.º 22
0
Common::UString Stack::getExactTypeAt(int index) const {
	if (!checkIndex(index)) {
		return "none";
	}

	const Common::UString type = tolua_typename(&_luaState, index);
	lua_pop(&_luaState, 1);
	return type;
}
Ejemplo n.º 23
0
Object listGet(void* state){
	int len = 2;
	Object objArr[2];
	getArgs(state, &len, objArr);
	Object* objs = objArr;
	List* l =(List*)objs[0].value.userData->data;
	size_t index = checkIndex(state, l, objs[1]);
	return l->vec[(size_t)index];
}
Ejemplo n.º 24
0
void OnlineSession::dropGrouping(int index)
{
    checkIndex(index);

    if (groupings[index] != NULL)
        delete groupings[index];

    groupings[index] = NULL;
}
int LinkedIntList::get(int index) const {
    checkLocked("get");
    checkIndex(index, 0, size() - 1);
    ListNode* current = front;
    for (int i = 0; i < index; i++) {
        current = current->next;
    }
    return current->data;
}
Ejemplo n.º 26
0
/*
 * Adds the given value just before the given 0-based index in the list,
 * shifting subsequent elements right as necessary to make room.
 * Throws a string exception if the index is out of bounds.
 */
void ArrayIntList::insert(int index, int value) {
    checkIndex(index, 0, mysize);
    ensureCapacity(mysize + 1);
    for (int i = mysize; i > index; i--) {
        elements[i] = elements[i - 1];
    }
    elements[index] = value;
    mysize++;
}
Ejemplo n.º 27
0
int TreeModel::columnCount(const QModelIndex &idx) const
{
    checkIndex(idx);
    if (!idx.isValid())
        return m_root->rowCount();
    if (idx.column() > 0)
        return 0;
    return itemFromIndex(idx)->columnCount();
}
Ejemplo n.º 28
0
 void insert(int theIndex, const T& theElement) {
     checkIndex(theIndex);
     //寻找前驱节点
     ChainNode<T>* p = headerNode;
     for (int i = 0; i < theIndex; i++) {
         p = p->next;
     }
     p->next = new ChainNode<T>(theElement,headerNode);
     ListSize ++;
 }
Ejemplo n.º 29
0
int OnlineSession::loadGrouping(int index, const char *path)
{
    checkIndex(index);

    if (groupings[index] != NULL)
        delete groupings[index];
        
    groupings[index] = new TimeSeriesGrouping(*dataSets[index], defaultST);
    return groupings[index]->fromFile(path);
}
Ejemplo n.º 30
0
	bool Joystick::verifyJoystick(int index)
	{
		if (!checkIndex(index))
			return false;

		if (!isOpen(index))
			return false;

		return true;
	}