static void rearrange (BTree* a, int pos) { if (pos==a->n) /* convert child index into key index */ pos--; BTree* left = a->p[pos]; BTree* right = a->p[pos+1]; if (left->n + right->n + 1 >= a->ordem) { /* redistribute */ while (underflow( left )) { addright(left, left->n, a->k[pos], right->p[0]); a->k[pos] = right->k[0]; delleft(right, 0); } while (underflow(right)) { addleft(right, 0, a->k[pos],left->p[left->n]); a->k[pos] = left->k[left->n-1]; delright(left, left->n-1); } } else { /* concatenate */ addright(left ,left->n,a->k[pos],right->p[0]); for (int i=0; i<right->n; ++i) addright(left, left->n, right->k[i], right->p[i+1]); free(right); delright(a, pos); } }
static void underflow0 (void) { underflow (-256); if (mpfr_get_emin () != MPFR_EMIN_MIN) underflow (mpfr_get_emin ()); underflow (MPFR_EMIN_MIN); }
void main() { int ch,item; while(1) { scanf("%d",&ch); switch(ch) { case 1: scanf("%d",&item); enqueue(item); break; case 2: if(underflow()==1) { printf("%d",front->info); dequeue(); } else { printf("Queue is empty"); } break; case 4: if(underflow()==1) { printf("\nThe queue is:\n"); show(); } else { printf("Queue is empty"); } break; case 3: if(underflow()==1) { printf("%d",front->info); } else { printf("Queue is empty"); } break; case 0: exit(1); default: printf("Enter valid choice"); break; } } }
int streambuf::sgetc() { #if 0 if (mgbeg == 0 || mgnext == mgend) { return underflow(); } return traits::to_int(*gptr()); #else return underflow(); #endif }
//read to buffer in place (apart from data already buffered) std::streamsize istreambuf::xsgetn(char *buffer, std::streamsize n) { LOG("bz::istreambuf::xsgetn (" << n << ")"); //try to satisfy request from buffered input std::streamsize available = egptr() - gptr(); int read = (available >= n)? n : available; if (read) { std::copy(gptr(), gptr() + read, buffer); gbump(read); } //inflate the rest directly into the user's buffer if (read < n) { if (end) { LOG("\tend of stream (EOF)"); //signal the stream has reached it's end return eof; } z_strm->next_out = buffer + read; z_strm->avail_out = n - read; if (0 < z_strm->avail_in) { decompress(); } while (!(end || 0 == z_strm->avail_out)) { read_decompress(); } underflow(); } return n; }
BigInt::reference BigInt::operator-= ( const_reference o ) { if ( sign_ ) { abs(); operator+= ( o ); return neg(); } else if ( o.sign_ ) { return operator+= ( -o ); } else if ( *this < o ) { BigInt t = o; t -= *this; return *this = -t; } for ( unsigned i = 0; i < o.buffer.size(); i++ ) { buffer[i]-=o.buffer[i]; if ( buffer[i] < 0 ) { buffer[i] += 10; buffer[i+1]--; // [i+1] exists because o <= *this ( or so I hope ) } } underflow ( o.buffer.size()-1 ); return normalize(); }
std::streamsize sockstreambuf_kernel_2:: xsgetn ( char_type* s, std::streamsize n ) { std::streamsize temp = n; while (n > 0) { int num = static_cast<int>(egptr() - gptr()); if (num >= n) { // copy data from our buffer std::memcpy(s, gptr(), static_cast<size_t>(n)); gbump(static_cast<int>(n)); return temp; } // read more data into our buffer if (num == 0) { if (underflow() == EOF) break; continue; } // copy all the data from our buffer std::memcpy(s, gptr(), num); n -= num; gbump(num); s += num; } return temp-n; }
//set a new position //if going too much back, restart the iterator streampos StringIteratorStreamBuf::seekoff ( streamoff off, ios_base::seekdir way, ios_base::openmode which ) { if(!(which & ios_base::in)) return -1; streampos targetpos; if(way == ios_base::end) { if(off > 0) return -1; while(underflow() != EOF); streampos maxpos = begin_offset + (streamoff)buffer[current_buffer].length(); targetpos = maxpos + off; } else if(way == ios_base::cur) { targetpos = begin_offset + (streamoff)(gptr() - eback()) + off; } else if(way == ios_base::beg) { if(off < 0) return -1; targetpos = off; } else return -1; return seekpos(targetpos, ios_base::in); }
//set a new position //if going too much back, restart the iterator streampos StringIteratorStreamBuf::seekpos ( streampos sp, ios_base::openmode which ) { if(!(which & ios_base::in)) return -1; if(sp < begin_offset) { setg(eback(), eback(), egptr()); pbackfail(EOF); if(sp < begin_offset) { //restart the iterator if(!reset()) return -1; buffer[0].resize(0); buffer[1].resize(0); current_buffer = last_buffer = 0; begin_offset = 0; is_eof = false; setg(NULL, NULL, NULL); } } while(sp >= (begin_offset+(streamoff)buffer[current_buffer].length())) { if(underflow() == EOF) { if(sp == (begin_offset+(streamoff)buffer[current_buffer].length())) break; return -1; } } setg(eback(), eback() + (streamoff)(sp - begin_offset), egptr()); return sp; }
static int rem (BTree* a, int x) { if (isleaf(a)) { int pos; if (findpos(a,x,&pos)) delleft(a,pos); /* or delright */ else return 0; } else { int pos; if (findpos(a,x,&pos)) { BTree* l = findmax(a->p[pos]); a->k[pos] = l->k[l->n-1]; l->k[l->n-1] = x; } if (!rem(a->p[pos],x)) return 0; if (underflow(a->p[pos])) rearrange(a,pos); } return 1; }
streamsize streambuf::do_sgetn( char *buf, streamsize len ) { streamsize available; streamsize returned; returned = 0; __lock_it( __b_lock ); while( len > 0 ) { // # characters left in buffer available = (__huge_ptr_int)(egptr() - gptr()); if( available <= 0 ) { // nothing left? if( underflow() == EOF ) break; available = (__huge_ptr_int)(egptr() - gptr()); } if( available > len ) { // too many? available = len; } memcpy( buf, gptr(), available ); gbump( available ); returned += available; buf += available; len -= available; } return( returned ); }
::std::streampos seekpos(::std::streampos sp, ::std::ios_base::openmode which = ::std::ios_base::in | ::std::ios_base::out) { if ( which & ::std::ios_base::in ) { int64_t const cur = symsread-(egptr()-gptr()); int64_t const curlow = cur - static_cast<int64_t>(gptr()-eback()); int64_t const curhigh = cur + static_cast<int64_t>(egptr()-gptr()); // call relative seek, if target is in range if ( sp >= curlow && sp <= curhigh ) return seekoff(static_cast<int64_t>(sp) - cur, ::std::ios_base::cur, which); // target is out of range, we really need to seek uint64_t tsymsread = (sp / buffersize)*buffersize; symsread = tsymsread; stream.clear(); stream.seekg( (symsread * b) / 8 ); setg(buffer.end(),buffer.end(),buffer.end()); underflow(); setg(eback(),gptr() + (static_cast<int64_t>(sp)-static_cast<int64_t>(tsymsread)), egptr()); return sp; } return -1; }
// --------- streamsize CEEStdStreamBufProxy::xsgetn(TCHAR *dest, streamsize sSize) { int nRead = 0; int avail; while (sSize) { // get number of character available avail = in_avail(); if (!avail) { if (underflow() == EOF) break; } if (avail > sSize) { avail = sSize; } memcpy(dest + nRead, gptr(), avail); gbump(avail); nRead += avail; sSize -= avail; } return nRead; }
int pop(){ if(isEmptyStack()){//if already empty underflow();//show underflow }else{ return mem[TOP--];//otherwise return val, decrement top location } }
/// Flushes the input. void ifstream::sync (void) { istringstream::sync(); underflow (0U); m_File.sync(); clear (m_File.rdstate()); }
int recDelete(rect *r, node *n, int pos){ int i,j; node *n1, *n2; if(n->leaf){ for(i = 0; i < n->size; ++i) if(n->values[i]->child == pos){ deleteValue(n, i); writeNode(n); return TRUE; } return FALSE; } for(i = 0; i < n->size; ++i) if(intersect(r, n->values[i]->r)){ n1 = readNode(n->values[i]->child); if(recDelete(r, n1, pos)){ n->values[i]->r = dupRect(n1->MBR); if(n1->size < b ) underflow(n, n1, i); else{ refreshMBR(n); writeNode(n); freeNode(n1); } return TRUE; } else freeNode(n1); } return FALSE; }
int peek(){ if(isEmptyStack()){//if already empty underflow();//show underflow }else{ return mem[TOP];//otherwise return val } }
dtn::data::MetaBundle Registration::receiveMetaBundle() throw (dtn::storage::NoBundleFoundException) { ibrcommon::MutexLock l(_receive_lock); while(true) { try { // get the first bundle in the queue dtn::data::MetaBundle b = _queue.pop(); return b; } catch (const ibrcommon::QueueUnblockedException &e) { if (e.reason == ibrcommon::QueueUnblockedException::QUEUE_ABORT) { IBRCOMMON_LOGGER_DEBUG_TAG(Registration::TAG, 25) << "search for more bundles" << IBRCOMMON_LOGGER_ENDL; // query for new bundles underflow(); } } catch(const dtn::storage::NoBundleFoundException & ){ } } throw dtn::storage::NoBundleFoundException(); }
SyncBuffer::int_type SyncBuffer::uflow() { int_type c = underflow(); if(c != traits_type::eof()) { std::lock_guard<std::mutex> lock(impl->mutex); impl->buffer.pop_front(); } return c; }
/// Reads at most \p n bytes into \p s. istream::size_type istream::readsome (void* s, size_type n) { if (remaining() < n) underflow (n); const size_type ntr (minV (n, remaining())); read (s, ntr); return (ntr); }
sockbuf::int_type sockbuf::uflow () { int_type ret = underflow (); if (ret == eof) return eof; gbump (1); return ret; }
streambuf::int_type streambuf::_M_snextc_underflow() { if (__M_gnext == __M_gend) { return (uflow() == EOF) ? EOF : sgetc(); } else { __M_gnext = __M_gend; return underflow(); } }
void Histogram<T>::print () const { std::cout << "Total: " << size() << ", " << "Min: " << _min << ", " << "Max: " << _max << '\n'; std::cout << std::left << std::setw(6) << "-1" << '(' << std::setw(5) << lowest() << "-) " << std::right << std::setw(6) << underflow() << '\n'; for (unsigned i=0; i<_bins; ++i) { std::cout << std::left << std::setw(6) << i << '(' << std::setw(5) << low(i) << ", " << std::setw(5) << high(i) << ")" << std::right << std::setw(6) << _bin[i] << '\n'; } std::cout << std::left << std::setw(6) << _bins << '(' << std::setw(5) << highest() << "+) " << std::right << std::setw(6) << overflow() << '\n'; }
std::streambuf::pos_type rdbuf::seekpos(pos_type target, std::ios_base::openmode which) { //std::cerr << ">> Absolute seek to " << target << "\n"; if (target < pos_) reset(); // TODO Optimize by checking if the seek destination is still in the get buffer while (pos_ + pos_type(egptr() - eback()) < target) { //int_type loadsize = underflow(); if (underflow() == traits_type::eof()) return pos_ + egptr() - gptr(); } setg(eback(), eback() + target - pos_, egptr()); return target; }
int TCPStream::uflow() { int ret = underflow(); if (ret == EOF) return EOF; if (bufsize != 1) gbump(1); return ret; }
CURLcode streambuf::curl_multi_info_read( bool throw_on_error ) { underflow(); CURLMsg *msg; int msgs_in_q; CURLcode code = CURLE_OK; while ( (msg = ::curl_multi_info_read( curlm_, &msgs_in_q )) ) if ( msg->msg == CURLMSG_DONE ) code = msg->data.result; if ( code && throw_on_error ) throw exception( "curl_multi_info_read()", "", code ); return code; }
/* function: sgetn parameters: char * - place to put read characters int - number of characters to try to read purpose: get characters from buffer and fill buffer if needed return: int - number of characters actually gotten */ int em_ios::sgetn(char *chrs, int num) { #define isdelim(x) isspace(x) int retVal, i; retVal = 1; for(i = 0; i < num; ++i) { if (bufICount>=bufLen) bufICount=0; if ((mode&em_ios::binary)==0) if(isdelim(buffer[bufICount])) { chrs[i] = buffer[bufICount++]; break; } if(bufICount > 0) { if ((mode&em_ios::binary)==0) { if(isdelim(buffer[bufICount])) { chrs[i] = buffer[bufICount++]; while(((mode&em_ios::binary)==0) && isdelim(buffer[bufICount++])) { if(bufICount >= bufLen) { --i; break; // remove whitespace } } --bufICount; } else chrs[i] = buffer[bufICount++]; } else chrs[i] = buffer[bufICount++]; } else { underflow('\r'); // get more, newline terminates getting // you may want to change the delimiter chrs[i] = buffer[bufICount++]; } } return(i); }
BigInt::reference BigInt::operator-- () { if ( sign_ || operator==(zero) ) { abs(); operator++ (); return neg(); } buffer[0]--; underflow(0); return normalize(); }
std::streamsize sockbuf::xsgetn (char_type* s, std::streamsize n) { std::streamsize rval = showmanyc (); if (rval >= n) { memcpy (s, gptr (), (size_t)(n * sizeof (char_type))); gbump ((int)n); return n; } memcpy (s, gptr (), (size_t)(rval * sizeof (char_type))); gbump ((int)rval); if (underflow () != eof) return rval + xsgetn (s + rval, n - rval); return rval; }
// find an empty space of a given size or eep int findhole(int size) { int starthole = STARTDB, endhole; for (;;) { if (starthole + size > ENDDB) break; // ain't gonna fit starthole = findunoccupied(starthole); // first byte of next hole, or if (starthole == FAIL) break; // outa holes endhole = findoccupied(starthole); // first byte or next block, or if (endhole == FAIL) endhole = ENDDB+1; // the first byte thou shall not touch // endhole is now on first char of next non-empty block, or one past ENDDB if ((endhole - starthole) >= size) return starthole; // success starthole = endhole; // find another hole } underflow(M_eeprom); return 0; // placate compiler }