int32_t FieldCacheTermsFilterDocIdSetIterator::nextDoc() {
    try {
        if (++doc >= fcsi->order.size()) {
            boost::throw_exception(IndexOutOfBoundsException());
        }
        while (!openBitSet->fastGet(fcsi->order[doc])) {
            if (++doc >= fcsi->order.size()) {
                boost::throw_exception(IndexOutOfBoundsException());
            }
        }
    } catch (IndexOutOfBoundsException&) {
        doc = NO_MORE_DOCS;
    }
    return doc;
}
void ComponentToRobot::setMotors(const motor* motors, int motornumber)
{
  int current_motor_count = 0;

  WireContainer::iterator it = wire_container.begin();
  for(int i = 0; i < motornumber; ++i) {
    //    std::cout << "MV = " << *motors << "\n";
    if(*motors < -1.0 || *motors > 1.0) {
      std::cerr << "invalid motor value\n";
      exit(-1);

    }

    IInputWire *p_input_wire = dynamic_cast<IInputWire*>(*it);
    if(NULL == p_input_wire)
      continue;


    if(wire_container.end() == it)
      IndexOutOfBoundsException().raise();

    ++current_motor_count;
    p_input_wire->put(*(motors++));

    ++it;
  }
}
/*Funkcja zwracaj¹ca wartoœæ elementu listy o zadanym indeksie.
Wyrzuca wyj¹tek "OutOfBoundException" przy otrzymaniu indexu 
wykraczaj¹cego poza listê. */
int LinkedList::get(int index){
	Node* node = search(index);
	if (node == nullptr)
		throw IndexOutOfBoundsException();
	else
		return node->value;
}
Exemple #4
0
//
// write()
//
ssize_t
OutputStream::write(const unsigned char* b, size_t size, size_t off, size_t len)
    throw(IOException, IllegalBlockingModeException, IndexOutOfBoundsException)
{
    // Comprueba los limites del array
    if (off + len > size)
    {
        throw IndexOutOfBoundsException("Index out of bounds");
    }

    // Delega la operacion en el canal, si este existe
    if (_channel)
    {
        SocketChannel* ch = dynamic_cast<SocketChannel*>(_channel);
        return ch->write(b+off, len);
    }

    // Escritura
    ssize_t n = ::write((int) _fd, (void*) (b + off), len);
    if (n == -1)
    {
        throw IOException("write() error", errno);
    }

    return n;
}
void CIMParameterRep::removeQualifier(Uint32 index)
{
    if (index >= _qualifiers.getCount())
        throw IndexOutOfBoundsException();

    _qualifiers.removeQualifier (index);
}
Array<CIMClass> clientRepositoryInterface::enumerateClasses(
    const CIMNamespaceName& nameSpace,
    const CIMName& className,
    const Boolean deepInheritance,
    const Boolean localOnly,
    const Boolean includeQualifiers,
    const Boolean includeClassOrigin) const
{
    if (_repository)
        return _repository->enumerateClasses(
                                    nameSpace,
                                    className,
                                    deepInheritance,
                                    localOnly,
                                    includeQualifiers,
                                    includeClassOrigin);

     if (_client)

       return _client->enumerateClasses(
                                    nameSpace,
                                    className,
                                    deepInheritance,
                                    localOnly,
                                    includeQualifiers,
                                    includeClassOrigin);
	 throw IndexOutOfBoundsException();
};
Exemple #7
0
	/** Field-access-operator for the vertical dimension.
	 * \param y The Y-coordinate inside the matrix.
	 * \return Reference to the \ref Field "field" at the given coordinates.
	 */
	Field& operator[](uint16_t y) const throw (IndexOutOfBoundsException)
	{
		if (y >= maxY)
			throw IndexOutOfBoundsException(y, maxY, 'Y');
		else
			return *x[y];
	}
Exemple #8
0
  mailsType::mail_p mailsType::element_mail_at(unsigned int idx)
  {
    if(idx > _list_mail.size()-1) {
      throw IndexOutOfBoundsException("IndexOutOfBoundsException");
    }

    return _list_mail.at(idx);
  }
Exemple #9
0
char String::operator [](const int index) const {
	if(index >= 0 && index < length) {
		return string[index];
	} else {
		throw IndexOutOfBoundsException(index);
		return 0;
	}
}
Array<CIMQualifierDecl> clientRepositoryInterface::enumerateQualifiers(
    const CIMNamespaceName& nameSpace) const 
{
  if (_repository)
    return _repository->enumerateQualifiers(nameSpace);
  if (_client)
      return _client->enumerateQualifiers(nameSpace);
	throw IndexOutOfBoundsException();
}
Exemple #11
0
T & Array<T>::operator [] ( int i ) 
throw(IndexOutOfBoundsException)
{
	if(!(0 <= i && i < len ))
	{
		throw IndexOutOfBoundsException("OutOfBoundsException Caught!");
	}
	return buf[i];
}
Exemple #12
0
void* PtrListIterator::next()
{
    if(_lead==NULL)
        throw IndexOutOfBoundsException();

    void* element = _lead->getElement();
    _lead = _lead->getNext();

    return element;
}
 int32_t FieldCacheTermsFilterDocIdSetIterator::advance(int32_t target)
 {
     try
     {
         doc = target;
         if (doc < 0 || doc >= fcsi->order.size())
             boost::throw_exception(IndexOutOfBoundsException());
         while (!openBitSet->fastGet(fcsi->order[doc]))
         {
             if (++doc >= fcsi->order.size())
                 boost::throw_exception(IndexOutOfBoundsException());
         }
     }
     catch (IndexOutOfBoundsException&)
     {
         doc = NO_MORE_DOCS;
     }
     return doc;
 }
void TrafficMatrixSequence::removeMatrix(unsigned int index) {
    if(index >= this->sequence.size())
        throw IndexOutOfBoundsException(index);

    sequenceType::iterator it = this->sequence.begin() + index;
    if(it == this->sequence.end() - 1)
        this->sequence.erase(it);
    else
        this->sequence[index] = TrafficMatrix();
}
	Kernel(const int width, const int height, const Index& anchor = Index(-1,-1))
	: GrayImage<T1>(width, height)
	{
		if ( this->isValidIndex(anchor) || anchor == Index(-1,-1) ) {
			mAnchor = anchor;
		}
		else {
			throw IndexOutOfBoundsException("Anchor not inside image in constructor Kernel(width, height, anchor)!");
		}
	} // end constructor
Array<CIMObjectPath> clientRepositoryInterface::enumerateInstanceNames(
	const CIMNamespaceName& nameSpace,
	const CIMName& className)
{
    if (_repository)
       return _repository->enumerateInstanceNames(nameSpace, className);

    if (_client)
       return _client->enumerateInstanceNames(nameSpace, className);
	throw IndexOutOfBoundsException();
};
Exemple #17
0
    bool NArray::deleteElement(const size_t index)
    {
        if (index > _children.size())
        {
            throw IndexOutOfBoundsException(index);
        }

        delete _children[index];
        _children.erase(_children.begin() + index);
        return true;
    }
Exemple #18
0
sp<ByteBuffer> ByteBuffer::put(const sp<ByteArray>& src, size_t offset, size_t size) {
    if (src == nullptr) {
        throw NullPointerException();
    }
    if ((offset + size) > src->size()) {
        throw IndexOutOfBoundsException();
    }
    checkBufferOverflow(mPosition, size);
    System::arraycopy(src, offset, mBuffer, mOffset + mPosition, size);
    mPosition += size;
    return this;
}
Exemple #19
0
sp<ByteBuffer> ByteBuffer::get(const sp<ByteArray>& dst, size_t offset, size_t count) {
    if (dst == nullptr) {
        throw NullPointerException();
    }
    if ((offset + count) > dst->size()) {
        throw IndexOutOfBoundsException();
    }
    checkBufferUnderflow(mPosition, count);
    System::arraycopy(mBuffer, mOffset + mPosition, dst, offset, count);
    mPosition += count;
    return this;
}
void ByteArrayOutputStream::write(const sp<ByteArray>& buffer, size_t offset, size_t count) {
    if (buffer == nullptr) {
        throw NullPointerException();
    }
    if ((offset + count) > buffer->size()) {
        throw IndexOutOfBoundsException();
    }

    if (count == 0) {
        return;
    }
    expand(count);
    System::arraycopy(buffer, offset, mBuffer, mCount, count);
    mCount += count;
}
CIMClass clientRepositoryInterface::getClass(
    const CIMNamespaceName& nameSpace,
    const CIMName& className,
    const Boolean localOnly,
    const Boolean includeQualifiers,
    const Boolean includeClassOrigin) const
{
    if (_repository)
        return _repository->getClass(nameSpace, className,
                        localOnly, includeQualifiers, includeClassOrigin);
    if (_client)
        return _client->getClass(nameSpace, className,
                        localOnly, includeQualifiers, includeClassOrigin);
	throw IndexOutOfBoundsException();
};
void
clientRepositoryInterface::init(_repositoryType type, 
                                const String &location)
{
  String message;
  // _ot = ot;
  if (type == REPOSITORY_INTERFACE_LOCAL)
  {
      _repository = new CIMRepository(location);
      // test to find if repository exists.
  }
  else if (type == REPOSITORY_INTERFACE_CLIENT) 
  {
    // create a CIMClient object and put it in _client
    try
    {
        Uint32 index = location.find (':');
        String host = location.subString (0, index);
        Uint32 portNumber = 0;
        if (index != PEG_NOT_FOUND)
        {
            String portStr = location.subString (index + 1, location.size ());
            sscanf (portStr.getCString (), "%u", &portNumber);
        }
        cout << "open " << host << " port " << portNumber << endl;
        _client = new CIMClient();
        _client->connect (host, portNumber, String::EMPTY, String::EMPTY);
    } 
    
    catch(Exception &e) 
    {
	  cerr << "Internal Error:" << e.getMessage() << endl;
      delete _client;
      _client = 0;
    }
  }
  else 
  {
	  throw IndexOutOfBoundsException();
  }
}
Exemple #23
0
Matrix Matrix::operator-(Matrix& matrix){
    
    // If the matrices are the same size (otherwise subtraction doesntwork)
    if(columns  == matrix.columns &&
       rows     == matrix.rows){
        
        Matrix newMatrix = Matrix(rows, columns);
        
        for (unsigned int i = 0; i < rows; i++) {
            
            for (unsigned int j =0; j < columns; j++) {
                
                newMatrix.getElement(i, j) =
                    getElement(i, j) - matrix.getElement(i,j);
            }
        }
        
        return newMatrix;
    }
    
    throw IndexOutOfBoundsException();
}
Array<CIMName> clientRepositoryInterface::enumerateClassNames(
    const CIMNamespaceName& nameSpace,
    const CIMName& className,
    const Boolean deepInheritance)

{
    if (_repository)
    {
       Array<CIMName> classNameArray = _repository->enumerateClassNames
           (nameSpace, className, deepInheritance);
       // ATTN: Temporary code until the repository uses CIMName
       Array<CIMName> cimNameArray;
       for (Uint32 i = 0; i < classNameArray.size(); i++)
       {
           cimNameArray.append(classNameArray[i]);
       }
       return cimNameArray;
    }

    if (_client)
       return _client->enumerateClassNames(nameSpace, className, deepInheritance);
	throw IndexOutOfBoundsException();
};
Exemple #25
0
int ComponentToRobot::getSensors(sensor* sensors, int sensornumber)
{
  WireContainer::iterator it_wire = wire_container.begin();

  int current_sensor = 0;

  for(int i = 0; i < sensornumber; ++i) {

    IOutputWire *p_output_wire = dynamic_cast<IOutputWire*>(*it_wire);

    if(NULL == p_output_wire)
      continue;

    if(wire_container.end() == it_wire)
      IndexOutOfBoundsException().raise();

    sensors[current_sensor] = p_output_wire->get();

    ++it_wire;
    ++current_sensor;
  }

  return current_sensor;
}
Exemple #26
0
    void NArray::deserialize(const std::string& iInput, const size_t idx, const size_t len)
    {
        if (len < 2 || iInput.size() < idx + len)
        {
            throw IndexOutOfBoundsException();
        }

        if (iInput[idx] != tokens::larray || iInput[idx + len - 1] != tokens::rarray)
        {
            throw TokenMatchingException(iInput.substr(idx, len), tokens::larray, tokens::rarray);
        }

        size_t i = idx + 1;
        while (i < idx + len - 1)
        {
            if (iInput[i] == tokens::quote || iInput[i] == tokens::lobject || iInput[i] == tokens::larray)
            {
                std::string tok = tokens::extractToken(iInput, i, idx + len - i - 1);
                i += tok.size();

                try
                {
                    _children.push_back(tokens::getObjectFromToken(tok));
                }
                catch (const NExceptionAbstract&) {}
            }
            else if (iInput[i] == tokens::separator || isspace(iInput[i]))
            {
                ++i;
            }
            else
            {
                throw NExceptionAbstract("Unexpected character in stream");
            }
        }
    }
TrafficMatrix TrafficMatrixSequence::getMatrix(unsigned int index) const {
    if(index >= this->sequence.size())
        throw IndexOutOfBoundsException(index);

    return this->sequence[index];
}
Exemple #28
0
//
// read()
//
ssize_t InputStream::read(unsigned char* b, size_t size, size_t off, size_t len)
    throw(IOException, IllegalBlockingModeException, IndexOutOfBoundsException)
{
    // Comprueba los limites del array
    if (off + len > size)
    {
        throw IndexOutOfBoundsException("Index out of bounds");
    }

    // Delega la operacion en el canal, si este existe
    if (_channel)
    {
        SocketChannel* ch = dynamic_cast<SocketChannel*>(_channel);
        return ch->read(b + off, len);
    }

    // Bytes leidos
    ssize_t n = -1;

    // Lee del stream si no se ha alcanzado EOF

    /* [email protected] 14/7/2004
    if (! eof())
    {
    */
        // Timeout in microseconds (by default, infinite timeout)
        struct timeval  tval_timeout;
        struct timeval* timeoutptr = NULL;
        if (_timeout)
        {
            tval_timeout.tv_sec  = ((long) _timeout) / 1000L;
            tval_timeout.tv_usec = 1000L * (((long) _timeout) % 1000L);
            timeoutptr = &tval_timeout;
        }

        // Comprueba si el stream esta listo para lectura
        fd_set rset;
        FD_ZERO(&rset);
        FD_SET((int) _fd, &rset);
        int error = select((int) _fd + 1, &rset, NULL, NULL, timeoutptr);
        if (error <= 0 || !FD_ISSET((int) _fd, &rset))
        {
            // Corrige errno para indicar vencimiento del timeout
            errno = (error == 0) ? ETIMEDOUT : errno;
        }
        else
        {
            // Lee del stream
            n = ::read((int) _fd, (void*) (b + off), len);
        }

        // Comprobacion de errores
        if (n == -1)
        {
            if (errno == ETIMEDOUT)
                throw SocketTimeoutException("read() timeout");
            else if (errno == EINTR)
                n = read(b, size, off, len);
            else
                throw IOException("read() error", errno);
        }

    /* [email protected]: 14/7/2004
    }
    */

    return n;
}
LanguageElement LanguageElementContainerRep::getLanguageElement(Uint32 index) const{
	if(index >= container.size())
	 	throw IndexOutOfBoundsException();
	return container[index];
} 
 double DoubleDocValues::doubleVal(int32_t doc)
 {
     if (doc < 0 || doc >= arr.size())
         boost::throw_exception(IndexOutOfBoundsException());
     return arr[doc];
 }