size_type total_size_with_header() const { return get_rounded_size ( size_type(sizeof(Header)) , size_type(::boost::container::container_detail::alignment_of<block_header<size_type> >::value)) + total_size(); }
XalanDOMString& XalanDOMString::append( const char* theString, size_type theCount) { invariants(); const size_type theLength = theCount == size_type(npos) ? length(theString) : theCount; if (theLength != 0) { if (empty() == true) { doTranscode(theString, theLength, theCount == size_type(npos), m_data, true); } else { XalanDOMCharVectorType theTempVector(getMemoryManager()); doTranscode(theString, theLength, theCount == size_type(npos), theTempVector, false); append(&*theTempVector.begin(), size_type(theTempVector.size())); } m_size = size_type(m_data.size()) - 1; assert(m_data.size() - 1 == m_size); } invariants(); return *this; }
inline size_type ReadFrom(const Packed &count) { auto result = size_type(); for (auto &element : (count | ranges::view::reverse)) { result <<= 8; result |= size_type(element); } return result; }
static Header *to_first_header(block_header<size_type> *bheader) { Header * hdr = reinterpret_cast<Header*>(reinterpret_cast<char*>(bheader) - get_rounded_size(size_type(sizeof(Header)), size_type(::boost::alignment_of<block_header<size_type> >::value))); //Some sanity checks return hdr; }
static block_header<size_type> *from_first_header(Header *header) { block_header<size_type> * hdr = reinterpret_cast<block_header<size_type>*>(reinterpret_cast<char*>(header) + get_rounded_size(size_type(sizeof(Header)), size_type(::boost::alignment_of<block_header<size_type> >::value))); //Some sanity checks return hdr; }
void stat_channel::second_tick(int tick_interval_ms) { int sample = int(size_type(m_counter) * 1000 / tick_interval_ms); TORRENT_ASSERT(sample >= 0); m_5_sec_average = size_type(m_5_sec_average) * 4 / 5 + sample / 5; m_30_sec_average = size_type(m_30_sec_average) * 29 / 30 + sample / 30; m_counter = 0; }
void stat_channel::second_tick(int tick_interval_ms) { int sample = int(size_type(m_counter) * 1000 / tick_interval_ms); LIBED2K_ASSERT(sample >= 0); m_samples.push_front(sample); m_samples.pop_back(); m_5_sec_average = std::accumulate(m_samples.begin(), m_samples.begin() + 5, 0) / 5; //m_5_sec_average = size_type(m_5_sec_average) * 4 / 5 + sample / 5; m_30_sec_average = size_type(m_30_sec_average) * 29 / 30 + sample / 30; m_counter = 0; }
typet string_abstractiont::build_type(whatt what) { typet type; switch(what) { case IS_ZERO: type=bool_typet(); break; case LENGTH: type=size_type(); break; case SIZE: type=size_type(); break; } return type; }
void XalanOutputStream::flushBuffer() { if (m_buffer.empty() == false) { CollectionClearGuard<BufferType> theGuard(m_buffer); assert(size_type(m_buffer.size()) == m_buffer.size()); doWrite(&*m_buffer.begin(), size_type(m_buffer.size())); } assert(m_buffer.empty() == true); }
void __vector__<_Tp, _Alloc>::_M_fill_insert( iterator __position, size_type __n, const _Tp& __x) { if (__n != 0) { if (size_type(this->_M_end_of_storage._M_data - this->_M_finish) >= __n) { _Tp __x_copy = __x; const size_type __elems_after = this->_M_finish - __position; pointer __old_finish = this->_M_finish; if (__elems_after > __n) { __uninitialized_copy(this->_M_finish - __n, this->_M_finish, this->_M_finish, _IsPODType()); this->_M_finish += __n; __copy_backward_ptrs(__position, __old_finish - __n, __old_finish, _TrivialAss()); _STLP_STD::fill(__position, __position + __n, __x_copy); } else { uninitialized_fill_n(this->_M_finish, __n - __elems_after, __x_copy); this->_M_finish += __n - __elems_after; __uninitialized_copy(__position, __old_finish, this->_M_finish, _IsPODType()); this->_M_finish += __elems_after; _STLP_STD::fill(__position, __old_finish, __x_copy); } } else _M_insert_overflow(__position, __x, _IsPODType(), __n); } }
void nsTSubstring_CharT::Adopt( char_type* data, size_type length ) { if (data) { ::ReleaseData(mData, mFlags); if (length == size_type(-1)) length = char_traits::length(data); mData = data; mLength = length; SetDataFlags(F_TERMINATED | F_OWNED); STRING_STAT_INCREMENT(Adopt); #ifdef NS_BUILD_REFCNT_LOGGING // Treat this as construction of a "StringAdopt" object for leak // tracking purposes. NS_LogCtor(mData, "StringAdopt", 1); #endif // NS_BUILD_REFCNT_LOGGING } else { SetIsVoid(true); } }
XalanDOMString& XalanDOMString::append( const XalanDOMChar* theString, size_type theCount) { const size_type theLength = theCount == size_type(npos) ? length(theString) : theCount; if (theLength != 0) { if (m_data.empty() == true) { m_data.reserve(theLength + 1); m_data.insert(m_data.end(), theString, theString + theLength); m_data.push_back(0); m_size = theLength; assert(length() == theLength); } else { m_data.insert(getBackInsertIterator(), theString, theString + theLength); m_size += theCount; } } invariants(); return *this; }
cw_context() : tags( *this, "tags" ), blocks( *this, "blocks" ), counts_per_block( *this, "counts_per_block" ), counts( *this, "counts" ), red_counts( *this, "red_counts" ), steps( *this, "counter" ), reduce( NULL ) { // here we wire the graph/reduction reduce = CnC::make_reduce_graph( *this, // context "reduce", // name counts_per_block, // input collection red_counts, // number of items per reduction counts, // the final result for each reduction std::plus<size_type>(), // the reduction operation size_type(0), // identity element // we use a lambda as the selector // it maps the item to the reduction identified by t.second (the string) // e.g. it reduces over all blocks []( const tag_type & t, std::string & _s )->bool{_s=t.second;return true;} ); tags.prescribes( steps, *this ); steps.consumes( blocks ); steps.produces( counts_per_block ); //CnC::debug::trace( *reduce, 3 ); }
void DrizzleIntegrationInterface::__NodeActivated( TreeBox& sender, TreeBox::Node& node, int col ) { int index = sender.ChildIndex( &node ); if ( index < 0 || size_type( index ) >= m_instance.p_inputData.Length() ) throw Error( "DrizzleIntegrationInterface: *Warning* Corrupted interface structures" ); DrizzleIntegrationInstance::DataItem& item = m_instance.p_inputData[index]; switch ( col ) { case 0: break; case 1: item.enabled = !item.enabled; UpdateInputDataItem( index ); break; case 2: { /* * ### TODO: Open drizzle data file and show a summary of drizzle data. */ } break; } }
QString StaticHelpers::toKbMbGb(size_type size, bool isSpped) { float val = size; char* SizeSuffix[] = { QT_TRANSLATE_NOOP("Torrent", " B"), QT_TRANSLATE_NOOP("Torrent", " Kb"), QT_TRANSLATE_NOOP("Torrent", " Mb"), QT_TRANSLATE_NOOP("Torrent", " Gb"), QT_TRANSLATE_NOOP("Torrent", " Tb"), QT_TRANSLATE_NOOP("Torrent", " Pb"), QT_TRANSLATE_NOOP("Torrent", " Eb"), QT_TRANSLATE_NOOP("Torrent", " Zb") }; char* SpeedSuffix[] = { QT_TRANSLATE_NOOP("Torrent", " B\\s"), QT_TRANSLATE_NOOP("Torrent", " Kb\\s"), QT_TRANSLATE_NOOP("Torrent", " Mb\\s"), QT_TRANSLATE_NOOP("Torrent", " Gb\\s"), QT_TRANSLATE_NOOP("Torrent", " Tb\\s"), QT_TRANSLATE_NOOP("Torrent", " Pb\\s"), QT_TRANSLATE_NOOP("Torrent", " Eb\\s"), QT_TRANSLATE_NOOP("Torrent", " Zb\\s") }; int i = 0; float dblSByte = val; if (size > KbInt) { for (i; size_type(val / KbInt) > 0; i++, val /= KbInt) { dblSByte = val / KbFloat; } } float fractpart, intpart; fractpart = modff(dblSByte, &intpart); QString str; if (fractpart < FLT_EPSILON) { str = QString::number(int(dblSByte)); } else { str = QString::number(dblSByte, 'f', i == 0 ? 0 : 2); } if (isSpped) { str.append(qApp->translate("Torrent", SpeedSuffix[i])); } else { str.append(qApp->translate("Torrent", SizeSuffix[i])); } return str; }
static const struct_info_t *memory_manager_type_is_struct (const type_t *self) { STRUCT_INFO_BEGIN(memory_manager); /* typed_t type */ STRUCT_INFO_RADD(typed_type(), type); /* manager_mmalloc_fun_t mmalloc; */ /* manager_mfree_fun_t mfree; */ /* manager_mrealloc_fun_t mrealloc; */ /* manager_mcalloc_fun_t mcalloc; */ STRUCT_INFO_RADD(funp_type(), mmalloc); STRUCT_INFO_RADD(funp_type(), mfree); STRUCT_INFO_RADD(funp_type(), mrealloc); STRUCT_INFO_RADD(funp_type(), mcalloc); /* manager_on_oom_fun_t on_oom; */ /* manager_on_err_fun_t on_err; */ STRUCT_INFO_RADD(funp_type(), on_oom); STRUCT_INFO_RADD(funp_type(), on_err); /* void *state; */ STRUCT_INFO_RADD(objp_type(), state); /* size_t state_size; */ STRUCT_INFO_RADD(size_type(), state_size); STRUCT_INFO_DONE(); }
void XalanDOMString::insert( iterator theInsertPosition, iterator theFirstPosition, iterator theLastPosition) { invariants(); if (m_data.empty() == true) { assert(theInsertPosition == m_data.end() || theInsertPosition == m_data.begin()); assign(theFirstPosition, theLastPosition); } else { m_data.insert(theInsertPosition, theFirstPosition, theLastPosition); m_size = size_type(m_data.size()) - 1; assert(m_size == m_data.size() - 1); } invariants(); }
bool EA::IO::FixedMemoryStream::SetPosition( off_type nPosition, PositionType positionType ) { switch (positionType) { case kPositionTypeBegin: EA_ASSERT(nPosition >= 0); mnPosition = (size_type)nPosition; // We deal with negative positions below. break; case kPositionTypeCurrent: mnPosition = mnPosition + (size_type)nPosition; // We have a signed/unsigned match, but the math should work anyway. break; case kPositionTypeEnd: mnPosition = mnSize + nPosition; // We deal with invalid resulting positions below. break; } // Deal with out-of-bounds situations that result from the above. if (mnPosition > mnSize) { EA_ASSERT( mnPosition < (size_type(-1) / 2) ); mnPosition = mnSize; return false; } return true; }
XalanDOMString::size_type XalanDOMString::length(const char* theString) { assert(theString != 0); #if defined(XALAN_STRICT_ANSI_HEADERS) assert(std::strlen(theString) < size_type(npos)); return size_type(std::strlen(theString)); #else assert(strlen(theString) < size_type(npos)); return size_type(strlen(theString)); #endif }
void nsTSubstring_CharT::Replace( index_type cutStart, size_type cutLength, const char_type* data, size_type length ) { // unfortunately, some callers pass null :-( if (!data) { length = 0; } else { if (length == size_type(-1)) length = char_traits::length(data); if (IsDependentOn(data, data + length)) { nsTAutoString_CharT temp(data, length); Replace(cutStart, cutLength, temp); return; } } cutStart = XPCOM_MIN(cutStart, Length()); if (ReplacePrep(cutStart, cutLength, length) && length > 0) char_traits::copy(mData + cutStart, data, length); }
void HDRCompositionInterface::__InputImages_NodeActivated( TreeBox& sender, TreeBox::Node& node, int col ) { int index = sender.ChildIndex( &node ); if ( index < 0 || size_type( index ) >= instance.images.Length() ) throw Error( "HDRCompositionInterface: *Warning* Corrupted interface structures" ); HDRCompositionInstance::ImageItem& item = instance.images[index]; switch ( col ) { case 0: break; case 1: item.enabled = !item.enabled; UpdateInputImagesItem( index ); break; case 2: { Array<ImageWindow> w = ImageWindow::Open( item.path ); for ( Array<ImageWindow>::iterator i = w.Begin(); i != w.End(); ++i ) i->Show(); } break; } }
void GradientsMergeMosaicInterface::__TargetImages_NodeActivated( TreeBox& sender, TreeBox::Node& node, int col ) { int index = sender.ChildIndex( &node ); if ( index < 0 || size_type( index ) >= instance.targetFrames.Length() ) throw Error( "GradientsMergeMosaicInterface: *Warning* Corrupted interface structures" ); GradientsMergeMosaicInstance::ImageItem& item = instance.targetFrames[index]; switch ( col ) { case 0: // Activate the item's index number: ignore. break; case 1: // Activate the item's checkmark: toggle item's enabled state. item.enabled = !item.enabled; UpdateTargetImageItem( index ); break; case 2: { // Activate the item's path: open the image. Array<ImageWindow> w = ImageWindow::Open( item.path ); for ( Array<ImageWindow>::iterator i = w.Begin(); i != w.End(); ++i ) i->Show(); } break; } }
// EXTRA MEMBER FUNCTIONS FOR DEBUG PRINTING void p_queue::print_tree(const char message[], size_type i) const // Pre: (none) // Post: If the message is non-empty, it has first been written to // cout. After that, the portion of the heap with root at // node i has been written to the screen. Each node's data // is indented 4*d, where d is the depth of the node. // NOTE: The default argument for message is the empty string, // and the default argument for i is zero. For example, // to print the entire tree of a p_queue p, with a // message of "The tree:", you can call: // p.print_tree("The tree:"); // This call uses the default argument i=0, which prints // the whole tree. { const char NO_MESSAGE[] = ""; size_type depth; if (message[0] != '\0') cout << message << endl; if (i >= used) cout << "(EMPTY)" << endl; else { depth = size_type( log( double(i+1) ) / log(2.0) + 0.1 ); if (2*i + 2 < used) print_tree(NO_MESSAGE, 2*i + 2); cout << setw(depth*3) << ""; cout << heap[i].data; cout << '(' << heap[i].priority << ')' << endl; if (2*i + 1 < used) print_tree(NO_MESSAGE, 2*i + 1); } }
void HDRCompositionInterface::__InputImages_CurrentNodeUpdated( TreeBox& sender, TreeBox::Node& current, TreeBox::Node& oldCurrent ) { int index = sender.ChildIndex( ¤t ); if ( index < 0 || size_type( index ) >= instance.images.Length() ) throw Error( "HDRCompositionInterface: *Warning* Corrupted interface structures" ); // ### If there's something that depends on which image is selected in the list, do it now. }
void DrizzleIntegrationInterface::__CurrentNodeUpdated( TreeBox& sender, TreeBox::Node& current, TreeBox::Node& oldCurrent ) { int index = sender.ChildIndex( ¤t ); if ( index < 0 || size_type( index ) >= m_instance.p_inputData.Length() ) throw Error( "DrizzleIntegrationInterface: *Warning* Corrupted interface structures" ); // ### If there's something that depends on which item is selected in the list, do it here. }
typename List<Type>::Iterator List<Type>::insert(Iterator position, const Type &value) { // insert the element [value] before [position] insert(position, size_type(1), value); // return iterator that point to the newly inserted element return --position; }
void stream_frontn(const Container& c, const Consumer& cons, size_type nb) { using const_pointer = typename Container::const_pointer; assert(c.size() >= nb); c.for_each_segment(c.begin(), c.begin() + nb, [&] (const_pointer lo, const_pointer hi) { size_type nb = size_type(hi - lo); cons(lo, nb); }); }
void CellTetrahedron::createGaussPoints( ) { lmx::DenseMatrix<double> gCoef( size_type(nGPoints), 5); // reference: http://www.cs.rpi.edu/~flaherje/pdf/fea6.pdf if (nGPoints == 1) { gCoef(0,0) = .25; gCoef(0,1) = .25; gCoef(0,2) = .25; gCoef(0,3) = .25; gCoef(0,4) = 1.; } else if(nGPoints == 4) { gCoef(0,0) = .585410196624969; gCoef(0,1) = gCoef(0,2) = gCoef(0,3) = .138196601125011; gCoef(0,4) = .25; gCoef(1,1) = .585410196624969; gCoef(1,0) = gCoef(1,2) = gCoef(1,3) = .138196601125011; gCoef(1,4) = .25; gCoef(2,2) = .585410196624969; gCoef(2,1) = gCoef(2,0) = gCoef(2,3) = .138196601125011; gCoef(2,4) = .25; gCoef(3,3) = .585410196624969; gCoef(3,1) = gCoef(3,2) = gCoef(3,0) = .138196601125011; gCoef(3,4) = .25; } // more on ... http://electromagnetics.biz/2D%20Gauss.txt // else if(nGPoints == 12){ // } // else if(nGPoints == 20){ // } for (int i=0; i<nGPoints; ++i) { gPoints.push_back ( new GaussPoint3D ( this->alpha, gCoef(i,4), jacobian, mat, i, bodyPoints[0]->getX() * gCoef(i,0) + bodyPoints[1]->getX() * gCoef(i,1) + bodyPoints[2]->getX() * gCoef(i,2) + bodyPoints[3]->getX() * gCoef(i,3), bodyPoints[0]->getY() * gCoef(i,0) + bodyPoints[1]->getY() * gCoef(i,1) + bodyPoints[2]->getY() * gCoef(i,2) + bodyPoints[3]->getY() * gCoef(i,3), bodyPoints[0]->getZ() * gCoef(i,0) + bodyPoints[1]->getZ() * gCoef(i,1) + bodyPoints[2]->getZ() * gCoef(i,2) + bodyPoints[3]->getZ() * gCoef(i,3), dc, true ) ); } }
void _VECTOR_IMPL<_Tp, _Alloc>::_M_fill_insert(iterator __pos, size_type __n, const _Tp& __x) { if (__n != 0) { if (size_type(this->_M_end_of_storage._M_data - this->_M_finish) >= __n) { _M_fill_insert_aux(__pos, __n, __x, _Movable()); } else _M_insert_overflow(__pos, __x, _TrivialCpy(), __n); } }
void stream_backn(const Container& c, const Consumer& cons, size_type nb) { using const_pointer = typename Container::const_pointer; assert(c.size() >= nb); size_type nb_before_target = c.size() - nb; c.for_each_segment(c.begin() + nb_before_target, c.end(), [&] (const_pointer lo, const_pointer hi) { size_type nb_items_to_copy = size_type(hi - lo); cons(lo, nb_items_to_copy); }); }