/* * display_tape() shows the local area of the tape around the head. */ void display_tape(int nLeft) { int pos; static int count = 0; for(pos = 0; pos < nLeft; pos++) { putchar(' '); } putchar('v'); putchar('\n'); for(pos = 0; pos < nLeft; pos++) { Left(); } for(pos = 0; pos < 79; pos++) { putchar(tape->symbol); Right(); } for(pos = 0; pos <(79 - nLeft); pos++) { Left(); } putchar('\n'); ++count; }
int main() { COORD pos; HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); int i, leftB, rightB, upB, downB; leftB = 11; rightB = 67; upB = 11; downB = 13; pos.Y = 12; pos.X = 66; for (i = 0; i < 12; i++) { pos = Left (pos, leftB); leftB--; pos = Up (pos, upB); upB--; pos = Right (pos, rightB); rightB++; pos = Down (pos, downB); downB++; } pos = Left (pos, leftB); leftB--; if (leftB == 0) { printf("*"); } pos.X = 0; pos.Y = 25; SetConsoleCursorPosition(hConsole, pos); SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); return 0; }
bool Intersects (Room &other, int *adjust_x = NULL, int *adjust_y = NULL) { if (Left() < other.Right() && Right() > other.Left() && Top() < other.Bottom() && Bottom() > other.Top()) { // Intersects, find the intersection distance if required. if (adjust_x != NULL) { // Work out if moving left or right is shorter. if (std::abs(Right() - other.Left()) > std::abs(other.Right() - Left())) { *adjust_x = other.Left() - Right(); } else { *adjust_x = other.Right() - Left(); } } if (adjust_y != NULL) { // Work out if moving up or down is shorter. if (std::abs(Bottom() - other.Top()) > std::abs(other.Bottom() - Top())) { *adjust_y = other.Top() - Bottom(); } else { *adjust_y = other.Bottom() - Top(); } } return true; } return false; }
void CCell::DrawTracker(CDC *pDC) { LOGPEN tLogPen; tLogPen.lopnColor=RGB(0,0,0); tLogPen.lopnStyle=PS_DOT; tLogPen.lopnWidth.x=1; CPen tPen; tPen.CreatePenIndirect(&tLogPen); CPen *pOldPen=(CPen *)pDC->SelectObject(&tPen); CBrush *pOldBrush=(CBrush *)pDC->SelectStockObject(NULL_BRUSH); pDC->SetROP2(R2_NOTXORPEN); long x1,y1,x2,y2; switch(m_lHitTarget){ case TK_CT: break; case TK_MOV: UPtoLP(Left(),Top(),&x1,&y1); UPtoLP(Right(),Bottom(),&x2,&y2); pDC->Rectangle(x1,y1,x2,y2); MoveInCell(m_potTracker); UPtoLP(Left(),Top(),&x1,&y1); UPtoLP(Right(),Bottom(),&x2,&y2); pDC->Rectangle(x1,y1,x2,y2); break; } pDC->SetROP2(R2_COPYPEN); pDC->SelectObject(pOldPen); pDC->SelectObject(pOldBrush); }
bool PolyChecker::IntersectProp(const DPoint2 &a, const DPoint2 &b, const DPoint2 &c, const DPoint2 &d) { if (Collinear(a, b, c) || Collinear(a, b, d) || Collinear(c, d, a) || Collinear(c, d, b)) return false; return Xor(Left(a, b, c), Left(a, b, d)) && Xor(Left(c, d, a), Left(c, d, b)); }
void CSoundOptionsMenu::Right() { if (!m_pRiotMenu || !m_pClientDE) return; CRiotClientShell* pClientShell = m_pRiotMenu->GetClientShell(); if (!pClientShell) return; CRiotSettings* pSettings = m_pRiotMenu->GetSettings(); if (!pSettings) return; if (m_nSelection == 0) { Left(); return; } else if (m_nSelection == 1) { if (!pSettings->MusicEnabled()) { pClientShell->DoMessageBox (IDS_NOMUSICCHANGE, TH_ALIGN_CENTER); return; } int nPos = m_sliderMusicVolume.GetPos(); if (nPos == m_sliderMusicVolume.GetMax()) return; m_sliderMusicVolume.SetPos (nPos + 1); pSettings->Sound[RS_SND_MUSICVOL].nValue = (LTFLOAT)m_sliderMusicVolume.GetPos() * 10; pSettings->ImplementMusicVolume(); } else if (m_nSelection == 2) { Left(); return; } else if (m_nSelection == 3) { if (!pSettings->SoundEnabled()) { pClientShell->DoMessageBox (IDS_NOSOUNDCHANGE, TH_ALIGN_CENTER); return; } int nPos = m_sliderSoundVolume.GetPos(); if (nPos == m_sliderSoundVolume.GetMax()) return; m_sliderSoundVolume.SetPos (nPos + 1); pSettings->Sound[RS_SND_SOUNDVOL].nValue = (LTFLOAT)m_sliderSoundVolume.GetPos() * 9; pSettings->ImplementSoundVolume(); } else if (m_nSelection == 4) { Left(); return; } CBaseMenu::Right(); }
//---------------------------------------------------------------------------// // DerivDraw // //---------------------------------------------------------------------------// void CMGTreeView::DerivDraw() { int Offset = m_ScrollBar->IsVisible() ? (int)(m_ScrollBar->GetPos() * (m_Root->GetTotalHeight() - Height() + 4)) : 0; g_pMGDD->FillRect(TRect(Left()+1, Top()+1, Width()-2, Height()-2), g_pMGDD->Skin()->Color(COL_EDIT_BG)); g_pMGDD->Rect(TRect(Left()+1, Top()+1, Width()-2, Height()-2), g_pMGDD->Skin()->Color(COL_EDIT_BORDER)); g_pMGDD->SetClipRect(TRect(Left()+2, Top()+6, Width()-4, Height()-8)); m_Root->Draw(Offset); g_pMGDD->SetClipRect(); }
App::PointInt Viewer::calculateWindowTopLeft(ResizePositionMethod method, const SizeInt &newSize ) { wxDisplay display(DisplayFromPointFallback(PositionScreen())); auto rtDesktop = wxToRect(display.GetClientArea()); switch (method) { case ResizePositionMethod::PositionToScreen: return rtDesktop.TopLeft() + RoundCast((rtDesktop.Dimensions() - newSize) * 0.5f); case ResizePositionMethod::PositionToCurrent: { auto pt = AnchorCenter() + RoundCast(newSize * -0.5f); if ((pt.X + newSize.Width) > rtDesktop.Right()) { pt.X = rtDesktop.Right() - newSize.Width; } else if (pt.X < rtDesktop.Left()) { pt.X = rtDesktop.Left(); } if (pt.Y + newSize.Height > rtDesktop.Bottom()) { pt.Y = rtDesktop.Bottom() - newSize.Height; } else if (pt.Y < rtDesktop.Top()) { pt.Y = rtDesktop.Top(); } AnchorTL(pt); return pt; } case ResizePositionMethod::PositionNothing: { // Cap to screen PointInt pt = AnchorTL(); if ((pt.X + newSize.Width) > rtDesktop.Right()) pt.X=rtDesktop.Right()-newSize.Width; else if (pt.X < rtDesktop.Left()) pt.X = rtDesktop.Left(); if ((pt.Y + newSize.Height) > rtDesktop.Bottom()) pt.Y=rtDesktop.Bottom()-newSize.Height; else if (pt.Y < rtDesktop.Top()) pt.Y=rtDesktop.Top(); AnchorCenter(pt + RoundCast(newSize * 0.5f)); return pt; } default: DO_THROW(Err::InvalidParam, "Invalid reposition method: " + ToAString(method)); } }
virtual void Flush(void) { if (!Active() || !m_fb) return; if (IsTrueColor()) { LOCK_PIXMAPS; while (cPixmapMemory *pm = dynamic_cast<cPixmapMemory *>(RenderPixmaps())) { const uint8_t *src = pm->Data(); char *dst = m_fb + (Left() + pm->ViewPort().Left()) * (m_vinfo.bits_per_pixel / 8 ) + (Top() + pm->ViewPort().Top()) * m_finfo.line_length; for (int y = 0; y < pm->DrawPort().Height(); y++) { memcpy(dst, src, pm->DrawPort().Width() * sizeof(tColor)); src += pm->DrawPort().Width() * sizeof(tColor); dst += m_finfo.line_length; } #if APIVERSNUM >= 20110 DestroyPixmap(pm); #else delete pm; #endif } } else { for (int i = 0; cBitmap *bitmap = GetBitmap(i); ++i) { int x1, y1, x2, y2; if (bitmap->Dirty(x1, y1, x2, y2)) { char *dst = m_fb + (Left() + bitmap->X0() + x1) * (m_vinfo.bits_per_pixel / 8 ) + (Top() + bitmap->Y0() + y1) * m_finfo.line_length; for (int y = y1; y <= y2; ++y) { tColor *p = (tColor *)dst; for (int x = x1; x <= x2; ++x) *p++ = bitmap->GetColor(x, y); dst += m_finfo.line_length; } bitmap->Clean(); } } } }
//---------------------------------------------------------------------------// // DerivDraw // //---------------------------------------------------------------------------// void CMGHotKey::DerivDraw() { string text = "None"; if (m_Char >= 0) { text = ""; //if (m_Ctrl ) text = "Ctrl + "; //if (m_Shift) text+= "Shift + "; text+= m_Char; } if (IsFocused()) { g_pMGDD->Rect (TRect(Left(), Top(), Width(), 20), g_pMGDD->Skin()->Color(COL_EDIT_BORDER_ACTIVE)); g_pMGDD->FillRect(TRect(Left()+1, Top()+1, Width()-2, 18), g_pMGDD->Skin()->Color(COL_EDIT_BG_ACTIVE)); g_pMGDD->SetClipRect(TRect(Left()+1, Top()+1, Width()-2, Height()-2)); g_pMGDD->TextDraw (FONT_NORMAL, Left()+3, Top(), 0,20, CMGFont::LEFT, CMGFont::VCENTER, g_pMGDD->Skin()->Color(COL_FONT_EDIT_ACTIVE), text); g_pMGDD->SetClipRect(); } else { g_pMGDD->Rect (TRect(Left(), Top(), Width(), 20), g_pMGDD->Skin()->Color(COL_EDIT_BORDER)); g_pMGDD->FillRect(TRect(Left()+1, Top()+1, Width()-2, 18), g_pMGDD->Skin()->Color(COL_EDIT_BG)); g_pMGDD->SetClipRect(TRect(Left()+1, Top()+1, Width()-2, Height()-2)); g_pMGDD->TextDraw (FONT_NORMAL, Left()+3, Top(), 0,20, CMGFont::LEFT, CMGFont::VCENTER, g_pMGDD->Skin()->Color(COL_FONT_EDIT), text); g_pMGDD->SetClipRect(); } }
/*--------------------------------------------------------------------- Returns true iff ab properly intersects cd: they share a point interior to both segments. The properness of the intersection is ensured by using strict leftness. ---------------------------------------------------------------------*/ bool IntersectProp( tPointi a, tPointi b, tPointi c, tPointi d ) { /* Eliminate improper cases. */ if ( Collinear(a,b,c) || Collinear(a,b,d) || Collinear(c,d,a) || Collinear(c,d,b) ) return FALSE; return Xor( Left(a,b,c), Left(a,b,d) ) && Xor( Left(c,d,a), Left(c,d,b) ); }
TBool CPage::KeyEvent(int aKeyCode) { ASSERT(iLayout); TBool result = ETrue; switch(aKeyCode) { case EKeyDevice3: Execute(); break; case EKeyLeftArrow: Left(); break; case EKeyRightArrow: Right(); break; case EKeyUpArrow: Up(); break; case EKeyDownArrow: Down(); break; default: result = EFalse; break; } return result; }
void LeftistHeap::Merge (MergeablePriorityQueue& queue) { LeftistHeap& arg = dynamic_cast<LeftistHeap&> (queue); if (IsEmpty ()) SwapContents (arg); else if (!arg.IsEmpty ()) { if (*key > *arg.key) SwapContents (arg); Right ().Merge (arg); if (Left ().nullPathLength < Right ().nullPathLength) Swap (left, right); nullPathLength = 1 + Min (Left ().nullPathLength, Right ().nullPathLength); } }
void ToStruct(JOYSTICK_FEATURE& feature) const { feature.name = new char[m_name.length() + 1]; feature.type = m_type; switch (m_type) { case JOYSTICK_FEATURE_TYPE_SCALAR: Primitive().ToStruct(feature.scalar.primitive); break; case JOYSTICK_FEATURE_TYPE_ANALOG_STICK: Up().ToStruct(feature.analog_stick.up); Down().ToStruct(feature.analog_stick.down); Right().ToStruct(feature.analog_stick.right); Left().ToStruct(feature.analog_stick.left); break; case JOYSTICK_FEATURE_TYPE_ACCELEROMETER: PositiveX().ToStruct(feature.accelerometer.positive_x); PositiveY().ToStruct(feature.accelerometer.positive_y); PositiveZ().ToStruct(feature.accelerometer.positive_z); break; case JOYSTICK_FEATURE_TYPE_MOTOR: Primitive().ToStruct(feature.motor.primitive); break; default: break; } std::strcpy(feature.name, m_name.c_str()); }
// Collision bool Sprite::CollisionBoundingBox(System::Graphics::Sprite* Other, int offset){ if (Bottom() - Other->Top() <= offset) return false; if (Other->Bottom() - Top() <= offset) return false; if (Right() - Other->Left() <= offset) return false; if (Other->Right() - Left() <= offset) return false; return true; }
/*--------------------------------------------------------------------- Performs the Graham scan on an array of angularly sorted points P. ---------------------------------------------------------------------*/ t_stack Graham(t_H2D h2) { t_stack top; int i; t_point p1, p2; /* Top two points on stack. */ /* Initialize stack. */ top = NULL; top = Push (&h2.point[0], top); top = Push (&h2.point[1], top); /* Bottom two elements will never be removed. */ i = 2; while (i < h2.nb_point) { //post("Stack at top of while loop, i = %d, vnum = %d :", i, P[i].vnum); //PrintStack( top ); if (!top->next) return NULL; // Failure p1 = top->next->p; p2 = top->p; if (Left(p1->v , p2->v, h2.point[i].v)) { top = Push(&h2.point[i], top); i++; } else top = Pop( top ); //PrintStack(top); } return top; }
void Maxheap(int Arr[],int ind){ //printf("came\n"); int lt=Left(ind)-1; //printf(" ld %d\n",lt); int largest; int rt=Right(ind)-1; //printf(" rd %d\n",rt); //printf(" heapsize %d\n",Hesize); if(lt<=Hesize) { //printf("if ld %d\n",lt); if(Arr[lt]>Arr[ind]){ largest=lt;} } else largest=ind; if(rt<=Hesize ){ //printf("if rd %d\n",rt); if(Arr[rt]>Arr[largest]) { largest=rt;} } if(largest!=ind) { Exg(ind,largest); Maxheap(Arr,largest); } }
/** * Draws ScaledImage * */ void ScaledImage::Draw() { if(!visible) return; int x,y,w,h; x=Left(); y=Top(); w=width; h=height; ImageData image=resourceManager.images[img.src]; int iW=image.width; int iH=image.width; //corners drawer->DrawImageSegment(x,y,leftBorder,topBorder,image.img, 0,0,leftBorder,topBorder); drawer->DrawImageSegment(x+w-rightBorder,y,rightBorder,topBorder,image.img, iW-rightBorder,0,rightBorder,topBorder); drawer->DrawImageSegment(x,y+h-bottomBorder,leftBorder,bottomBorder,image.img, 0,iH-bottomBorder,leftBorder,bottomBorder); drawer->DrawImageSegment(x+w-rightBorder,y+h-bottomBorder,rightBorder,bottomBorder,image.img, iW-rightBorder,iH-bottomBorder,rightBorder,bottomBorder); // sides drawer->DrawImageSegment(x+leftBorder,y,w-(leftBorder+rightBorder),topBorder,image.img, leftBorder,0,iW-(leftBorder+rightBorder),topBorder); drawer->DrawImageSegment(x+leftBorder,y+h-bottomBorder,w-(leftBorder+rightBorder),bottomBorder,image.img, leftBorder,iH-bottomBorder,iW-(leftBorder+rightBorder),bottomBorder); drawer->DrawImageSegment(x,y+topBorder,leftBorder,h-(topBorder+bottomBorder),image.img, 0,topBorder,leftBorder,iH-(topBorder+bottomBorder)); drawer->DrawImageSegment(x+w-rightBorder,y+topBorder,rightBorder,h-(topBorder+bottomBorder), image.img, iW-rightBorder,topBorder,rightBorder,iH-(topBorder+bottomBorder)); drawer->DrawImageSegment(x+leftBorder,y+topBorder,w-(leftBorder+rightBorder),h-(topBorder+bottomBorder),image.img, leftBorder,topBorder,iW-(leftBorder+rightBorder),iH-(topBorder+bottomBorder)); CQMLGUI::Element::Draw(); }
BOOL CxString :: Teilen( CString& h, CString& r, const char* pat, BOOL trimmen ) { CxString head = h; CxString rest = r; BOOL result = FALSE; ASSERT( AfxIsValidString( pat )); if ( *pat == '\0' ) { head = *this; rest = ""; if ( trimmen ) { head.TrimAll(); rest.TrimAll(); } h = head; r = rest; return TRUE; } if ( *(pat + 1 ) == '\0' ) return Teilen( h, r, *pat, trimmen ); int i = Find( pat ); int len = lstrlen( pat ); if ( len >= GetLength()) return FALSE; if ( i >= 0 ) { if ( i == 0 ) // pat steht am Anfang { head.Empty(); rest = Mid( len ); } else { head = Left( i ); if (( i + len ) < GetLength()) rest = Mid( i + len ); else rest = ""; result = TRUE; } } else { // pat nicht gefunden! head = *this; rest.Empty(); } if ( trimmen ) { head.TrimAll(); rest.TrimAll(); } h = head; r = rest; return result; } // Teilen
/** * Mouse scrolled event * * * @param x coordinate * @param y coordinate * @param relative x scroll * @param relative y scroll * * @return 1 if event was sucessfully processed and caught, 0 otherwise */ int MouseArea::MouseScrolled(int x, int y, int relx, int rely) { if(!enabled) return 0; int x1,y1,w,h; Rectangle* me; int processed=Element::MouseScrolled(x,y,relx,rely); if(processed!=0) return processed; me=(Rectangle* )this; x1=Left(); y1=Top(); w=width; h=height; if(x1<x && x<x1+w && y1<y && y<y1+h) { if(CustomMouseScrolled!=0) { CQMLMouseEvent e; e.x=x; e.y=y; e.relativeX=relx; e.relativeY=rely; CustomMouseScrolled(this->CustomMouseScrolled_context, e); } return 1; } return 0; }
/** * Mouse pressed event * * * @param x coordinat * @param y coordinate * @param button code * * @return 1 if event was sucessfully processed and caught, 0 otherwise */ int MouseArea::MousePressed(int x, int y, int button) { if(!enabled) return 0; int x1,y1,w,h; Rectangle* me; int processed=Element::MousePressed(x,y,button); if(processed!=0) return processed; me=(Rectangle* )this; x1=Left(); y1=Top(); w=width; h=height; if(x1<x && x<x1+w && y1<y && y<y1+h) { pressedElements.push_back(this); lastPressed=this; if(CustomMousePressed!=0) { CQMLMouseEvent e; e.x=x; e.y=y; e.button=button; CustomMousePressed(this->CustomMousePressed_context, e); } return 1; } return 0; }
// this : "c:\\temp\\1.txt" // return : "c:\\temp" CString CFileString::GetDirName() { int iLoc = ReverseFind('\\'); if (iLoc == -1) return ""; return Left(iLoc); }
menu_t *MenuProcessButtonCmd(menu_t *menu, int cmd) { if (AnyButton(cmd) || (!MenuTypeLeftRightMoves(menu->type) && (Left(cmd) || Right(cmd)))) { menu_t *subMenu = &menu->u.normal.subMenus[menu->u.normal.index]; switch (subMenu->type) { case MENU_TYPE_NORMAL: case MENU_TYPE_OPTIONS: case MENU_TYPE_CAMPAIGNS: case MENU_TYPE_KEYS: return subMenu; case MENU_TYPE_CAMPAIGN_ITEM: MenuLoadCampaign(&subMenu->u.campaign); return subMenu; // caller will check if subMenu type is CAMPAIGN_ITEM case MENU_TYPE_BACK: return menu->parentMenu; case MENU_TYPE_QUIT: return subMenu; // caller will check if subMenu type is QUIT case MENU_TYPE_RETURN: return subMenu; default: MenuActivate(subMenu, cmd); break; } } return NULL; }
inline bool IsCollidedRect(const cRectf& rect) { return (!((Right()<rect.Left()) ||(Left()>rect.Right()) ||(Top()>rect.Bottom()) ||(Bottom()<rect.Top()))); }
bool BoundConjunctiveConstraint::Subsume(BoundConstraint* that) const { BoundConstraint* left = Left(); BoundConstraint* right = Right(); if (that->IsBinaryConstraint()) { BoundBinaryConstraint* thatBinaryConstraint = static_cast<BoundBinaryConstraint*>(that); BoundConstraint* thatLeft = thatBinaryConstraint->Left(); BoundConstraint* thatRight = thatBinaryConstraint->Right(); bool leftSubsumeThatLeft = left->Subsume(thatLeft); bool rightSubsumeThatLeft = right->Subsume(thatLeft); bool leftSubsumeThatRight = left->Subsume(thatRight); bool rightSubsumeThatRight = right->Subsume(thatRight); bool leftOrRightSubsumeThatLeft = leftSubsumeThatLeft || rightSubsumeThatLeft; bool leftOrRightSubsumeThatRight = leftSubsumeThatRight || rightSubsumeThatRight; if (that->IsConjunctiveConstraint()) { return leftOrRightSubsumeThatLeft && leftOrRightSubsumeThatRight; } else if (that->IsDisjunctiveConstraint()) { return leftOrRightSubsumeThatLeft || leftOrRightSubsumeThatRight; } else // assert(false) { return false; } } else { bool leftSubsumeThat = left->Subsume(that); bool righSubsumeThat = right->Subsume(that); return leftSubsumeThat || righSubsumeThat; } }
void CText::DrawHotPoints(CDC *pDC) { LOGPEN tLogPen; tLogPen.lopnColor=RGB(0,0,0); tLogPen.lopnStyle=PS_DOT; tLogPen.lopnWidth.x=1; CPen tPen; tPen.CreatePenIndirect(&tLogPen); CPen *pOldPen=(CPen *)pDC->SelectObject(&tPen); CBrush *pOldBrush=(CBrush *)pDC->SelectStockObject(NULL_BRUSH); pDC->SetROP2(R2_NOTXORPEN); long x1,y1,x2,y2; UPtoLP(Left()-DELTA,Top()-DELTA,&x1,&y1); UPtoLP(Right()+DELTA,Bottom()+DELTA,&x2,&y2); pDC->Rectangle(x1,y1,x2,y2); /* pDC->SelectStockObject(GRAY_BRUSH); pDC->SelectStockObject(NULL_PEN); pDC->SetROP2(R2_NOT); long x5,y5,x6,y6; UPtoLP((m_lx1+m_lx2)/2,m_ly1-DELTA,&x5,&y5); UPtoLP((m_lx1+m_lx2)/2,m_ly2+DELTA,&x6,&y6); DrawHotPoint(pDC,x5,y5); DrawHotPoint(pDC,x6,y6); */ pDC->SetROP2(R2_COPYPEN); pDC->SelectObject(pOldBrush); pDC->SelectObject(pOldPen); pDC->SelectObject(pOldBrush); }
bool CBasePoly::InsideDiagonal( uint32 a, uint32 b ) { uint32 a_plus_1, a_minus_1; a_plus_1 = m_Indices.NextI( a ); a_minus_1 = m_Indices.PrevI( a ); if( LeftOn(a_minus_1, a, a_plus_1) ) { return Left(a, b, a_minus_1) && Left(b, a, a_plus_1); } else { return !( LeftOn(a, b, a_plus_1) && LeftOn(b, a, a_minus_1) ); } }
BOOL CxString :: Teilen( CString& h, CString& r, char c, BOOL trimmen ) { int i = Find( c ); CxString head = h; CxString rest = r; BOOL result = FALSE; if( i > 0 ) { head = Left( i ); rest = Mid( i + 1 ); result = TRUE; } else if( i == 0 ) { // c ist erstes Zeichen head.Empty(); rest = Mid( 1 ); } else { // Zeichen nicht gefunden! head = *this; rest.Empty(); } if ( trimmen ) { head.TrimAll(); rest.TrimAll(); } h = head; r = rest; return result; } // Teilen
/* * Maintain the heap order property (parent is smaller than children) which * may only be violated at ELM downwards. Assumes caller has locked the heap. */ static void _heap_ify_down(heap * hp, heap_node * elm) { heap_node *kid; int left = 0, right = 0; int true = 1; while (true) { left = Left(elm->id); right = Right(elm->id); if (!_heap_node_exist(hp, left)) { /* At the bottom of the heap (no child). */ assert(!_heap_node_exist(hp, right)); break; } else if (!_heap_node_exist(hp, right)) /* Only left child exists. */ kid = hp->nodes[left]; else { if (hp->nodes[right]->key < hp->nodes[left]->key) kid = hp->nodes[right]; else kid = hp->nodes[left]; } if (elm->key <= kid->key) break; _heap_swap_element(hp, kid, elm); } }
bool Rectangle::Intersect(const Rectangle& other) const { return (Left() < other.Right()) && (Right() > other.Left()) && (Top() < other.Bottom()) && (Bottom() > other.Top()); }