void
RemoveRand
	(
	JHashTable< JStrValue<int> >* const table,
	const JSize                 listLength,
	const JHashValue*     const hashList,
	const JStrValue<int>* const valueList,
	      int*            const countList
	)
{
	const JIndex firstEl = gRand.UniformLong(0, listLength-1);
	JIndex el = firstEl;
	while (countList[el] == 0)
		{
		++el;
		if (el == firstEl)
			{
			if (table->GetElementCount() != 0)
				{
				PrintError(__LINE__);
				}
			return;
			}
		}

	RemoveElement(el, table, kElementNum, hashList, valueList, countList);
}
Esempio n. 2
0
	bool CDXUIManager::AddRadioButton(UINT id, UINT group, float fCentreX, float fCentreY, float fRadius)
	{
		DXUIElement* pNew = AddElement(id);
		if (pNew)
		{
			DXRadioButtonGroup* pGroup;
			DXUIRadioButtonGroupMapIterator iter = m_mapRadioButtonGroups.find(group);
			if (iter != m_mapRadioButtonGroups.end())
			{
				pGroup = iter->second;
			}
			else
			{
				pGroup = new DXRadioButtonGroup();
				pGroup->uiActiveId = (UINT)-1;
				m_mapRadioButtonGroups.insert(DXUIRadioButtonGroupMap::value_type(group, pGroup));
			}

			CDXUIRadioButton* pRadio = new CDXUIRadioButton();
			if (FAILED(pRadio->Create(pGroup, fCentreX, fCentreY, fRadius)))
			{
				DX_SAFE_DELETE(pRadio);
				RemoveElement(pNew);

				return false;
			}
			pRadio->m_pSprite = m_pSprite;
			pRadio->m_pUIManager = this;

			pNew->pElement = pRadio;
		}

		return true;
	}
Esempio n. 3
0
File: main.c Progetto: f2008700/BITS
int main()
{
	SmallSet S1, S2, S3;
	int x,M,N,i;
	/********** Create Set S1 **********/
	S1=CreateSet();
	printf("S1 set is \n");
	Print(S1);
	/********** Create Set S2 **********/
	S2=CreateSet();
	printf("S2 set is \n");
	Print(S2);
	
	printf("Enter the number of Elements in S1 and S2\n");
	scanf("%d%d",&M,&N);
	/********* Add Elements to S1 ******/
	printf("Add Elements to S1\n");
	for(i=0;i<M;i++)
	{
		printf("Enter the Element\n");
		scanf("%d",&x);
		S1=AddElement(x,S1);
	}
	printf("Add Elements to S2\n");
	for(i=0;i<N;i++)
	{
		printf("Enter the Element\n");
		scanf("%d",&x);
		S2=AddElement(x,S2);
	}
	printf("The Set S1 after Addition\n");
	Print(S1);
	printf("The Set S2 after Addition\n");
	Print(S2);
	printf("Enter the Element to Delete from S1\n");
	scanf("%d",&x);
	S1=RemoveElement(x,S1);
	printf("Union of S1 and S2 sets are\n");
	S3=Union(S1,S2);
	Print(S3);
	printf("Intersection of S1 and S2 sets are\n");
	S3=Intersect(S1,S2);
	Print(S3);
	printf("Complement of set S1 is\n");
	S3=Complement(S1);
	Print(S3);
	printf("Is set S1 EQUALS set S2 ?\n");
	if(Equals(S1,S2))
		printf("The Sets are EQUAL\n");
	else
		printf("The Sets are NOT EQUAL\n");
	printf("Enter the value for finding element\n");
	scanf("%d",&x);
	if(isElementOf(x,S1))
		printf("The value %d is AVAILABLE in S1\n",x);
	else
		printf("The value %d is NOT AVAILABLE in S1\n",x);

return 0;
}
Esempio n. 4
0
BOOL CCfgFile::RemoveElement(LPCTSTR pGroup, LPCTSTR pElement)
{_STTEX();
	HGROUP hGroup = FindGroup( pGroup );
	LPCFGELEMENTINFO pcei = FindElement( hGroup, pElement );

	return RemoveElement( hGroup, pcei );
}
Esempio n. 5
0
void ezQtPropertyContainerWidget::UpdateElements()
{
  ezQtScopedUpdatesDisabled _(this);

  ezUInt32 iElements = GetRequiredElementCount();

  while (m_Elements.GetCount() > iElements)
  {
    RemoveElement(m_Elements.GetCount() - 1);
  }
  while (m_Elements.GetCount() < iElements)
  {
    AddElement(m_Elements.GetCount());
  }

  for (ezUInt32 i = 0; i < iElements; ++i)
  {
    UpdateElement(i);
  }

  // Force re-layout of parent hierarchy to prevent flicker.
  QWidget* pCur = m_pGroup;
  while (pCur != nullptr && qobject_cast<QScrollArea*>(pCur) == nullptr)
  {
    pCur->updateGeometry();
    pCur = pCur->parentWidget();
  }
}
Esempio n. 6
0
//=================================================================================================
void DialogBox::Update(float dt)
{
	result = -1;

	for(vector<Button>::iterator it = bts.begin(), end = bts.end(); it != end; ++it)
	{
		it->mouse_focus = focus;
		it->Update(dt);
	}

	if(Key.Focus() && focus && result == -1)
	{
		if(bts[0].state != Button::DISABLED)
		{
			if(Key.PressedRelease(VK_ESCAPE))
				result = (type == DIALOG_OK ? BUTTON_OK : BUTTON_NO);
			else if(Key.PressedRelease(VK_RETURN) || Key.PressedRelease(VK_SPACE))
				result = (type == DIALOG_OK ? BUTTON_OK : BUTTON_YES);
		}
	}

	if(result != -1)
	{
		RemoveElement(GUI.created_dialogs, this);
		if(event)
			event(result);
		if(GUI.CloseDialog(this))
			delete this;
	}
}
Esempio n. 7
0
static void
pkunk_intelligence (ELEMENT *ShipPtr, EVALUATE_DESC *ObjectsOfConcern,
		COUNT ConcernCounter)
{
	STARSHIP *StarShipPtr;
	HELEMENT hPhoenix;

	GetElementStarShip (ShipPtr, &StarShipPtr);
	hPhoenix = (HELEMENT) StarShipPtr->RaceDescPtr->data;
	if (hPhoenix && (StarShipPtr->control & STANDARD_RATING))
	{
		RemoveElement (hPhoenix);
		FreeElement (hPhoenix);
		StarShipPtr->RaceDescPtr->data = 0;
	}

	if (StarShipPtr->RaceDescPtr->ship_info.energy_level <
			StarShipPtr->RaceDescPtr->ship_info.max_energy
			&& (StarShipPtr->special_counter == 0
			|| (BYTE)TFB_Random () < 20))
		StarShipPtr->ship_input_state |= SPECIAL;
	else
		StarShipPtr->ship_input_state &= ~SPECIAL;
	ship_intelligence (ShipPtr, ObjectsOfConcern, ConcernCounter);
}
void FNavigationOctree::AppendToNode(const FOctreeElementId& Id, INavRelevantInterface* NavElement, const FBox& Bounds, FNavigationOctreeElement& Element)
{
	FNavigationOctreeElement OrgData = GetElementById(Id);

	Element = OrgData;
	Element.Bounds = Bounds + OrgData.Bounds.GetBox();

	if (NavElement)
	{
		SCOPE_CYCLE_COUNTER(STAT_Navigation_GatheringNavigationModifiersSync);
		NavElement->GetNavigationData(*Element.Data);
	}

	// shrink arrays before counting memory
	// it will be reallocated when adding to octree and RemoveNode will have different value returned by GetAllocatedSize()
	Element.Shrink();

	const int32 OrgElementMemory = OrgData.GetAllocatedSize();
	const int32 NewElementMemory = Element.GetAllocatedSize();
	const int32 MemoryDelta = NewElementMemory - OrgElementMemory;

	NodesMemory += MemoryDelta;
	INC_MEMORY_STAT_BY(STAT_Navigation_CollisionTreeMemory, MemoryDelta);

	RemoveElement(Id);
	AddElement(Element);
}
void FNavigationOctree::UpdateNode(const FOctreeElementId& Id, const FBox& NewBounds)
{
	FNavigationOctreeElement ElementCopy = GetElementById(Id);
	RemoveElement(Id);
	ElementCopy.Bounds = NewBounds;
	AddElement(ElementCopy);
}
Esempio n. 10
0
void FNavigationOctree::RemoveNode(const FOctreeElementId& Id)
{
	FNavigationOctreeElement& Element = GetElementById(Id);
	const int32 ElementMemory = Element.GetAllocatedSize();
	NodesMemory -= ElementMemory;
	DEC_MEMORY_STAT_BY(STAT_Navigation_CollisionTreeMemory, ElementMemory);

	RemoveElement(Id);
}
Esempio n. 11
0
void ezQtPropertyContainerWidget::Clear()
{
  while (m_Elements.GetCount() > 0)
  {
    RemoveElement(m_Elements.GetCount() - 1);
  }

  m_Elements.Clear();
}
void FNavigationOctree::RemoveNode(const FOctreeElementId* Id)
{
#if NAVOCTREE_CONTAINS_COLLISION_DATA
	FNavigationOctreeElement& Data = GetElementById(*Id);
	const int32 ElementMemory = Data.GetAllocatedSize();
	NodesMemory -= ElementMemory;
	DEC_MEMORY_STAT_BY(STAT_Navigation_CollisionTreeMemory, ElementMemory);
#endif

	RemoveElement(*Id);
}
Esempio n. 13
0
    void EntityManager::UpdateEntities() {
    	while (destructionQueue.size()) {
    		Entity *ent = map[destructionQueue.front()];
    		RemoveElement(destructionQueue.front().c_str());
    		destructionQueue.pop_back();
    		delete ent;
    	}

        for (typename Hashmap::iterator it = map.begin(); it != map.end(); it++) {
            it->second->Update();
        }
    }
void
GRaggedFloatTableData::RemoveAllElements
	(
	const JIndex col
	)
{
	JArray<JFloat>* dataCol = itsCols->NthElement(col);
	const JSize rowCount = dataCol->GetElementCount();
	for (JSize i = 1; i <= rowCount; i++)
		{
		RemoveElement(1, col);
		}
}
Esempio n. 15
0
void RemoveStructureInterface(linkedList *list)
{
	char name[256];

	printf("Enter name:\n");
	fgets(name, 256, stdin);
	name[strlen(name) - 1] = '\0';

	if (!RemoveElement(list, FindElementByName(list, name)))
	{
		printf("Could not find the entry named '%s'\n", name);
	}
}
Esempio n. 16
0
File: Trial.cpp Progetto: komrok/uwp
unsigned int Trial::Run()
{
   int num = strings.size();

   Clear();

   timer.ReStart();

   for ( int r = 0; r < numRuns; r++ )
   {
      for ( int i = 0; i < num; i++ )
         AddElement(i);

      for ( int i = 0; i < num; i++ )
      {
         if( type == SORTED )
            RemoveElement(i);
         else
            RemoveElement();
      }
   }

   return timer.ElaspedTime();
}
void
GRaggedFloatTableData::MoveElement
	(
	const JIndex origRow,
	const JIndex origCol,
	const JIndex newRow,
	const JIndex newCol
	)
{
	JFloat value;
	if (GetElement(origRow, origCol, &value))
		{
		InsertElement(newRow, newCol, value);
		RemoveElement(origRow, origCol);
		}
}
Esempio n. 18
0
	bool CDXUIManager::AddStatic(UINT id, WCHAR* szText, float fX, float fY, float fFontSize)
	{
		DXUIElement* pNew = AddElement(id);
		if (pNew)
		{
			CDXUIStatic* pStatic = new CDXUIStatic();
			if (FAILED(pStatic->Create(szText, fX, fY, fFontSize)))
			{
				DX_SAFE_DELETE(pStatic);
				RemoveElement(pNew);

				return false;
			}

			pNew->pElement = pStatic;
		}

		return true;
	}
Esempio n. 19
0
	bool CDXUIManager::AddEditBox(UINT id, UINT maxLength, float fUpperLeftX, float fUpperLeftY, float fWidth, float fHeight)
	{
		DXUIElement* pNew = AddElement(id);
		if (pNew)
		{
			CDXUIEditBox* pEdit = new CDXUIEditBox();
			if (FAILED(pEdit->Create(maxLength, fUpperLeftX, fUpperLeftY, fWidth, fHeight)))
			{
				DX_SAFE_DELETE(pEdit);
				RemoveElement(pNew);

				return false;
			}
			pEdit->m_pUIManager = this;
			pEdit->m_pSprite = m_pSprite;

			pNew->pElement = pEdit;
		}

		return true;
	}
void
GRaggedFloatTableData::RemoveRow
	(
	const JIndex index
	)
{
	assert( index < GetRowCount() );

	const JSize colCount = itsCols->GetElementCount();
	for (JIndex i=1; i<=colCount; i++)
		{
		JArray<JFloat>* colData = itsCols->NthElement(i);
		const JSize rowCount = colData->GetElementCount();

		if (index <= rowCount)
			{
			RemoveElement(index, i);
			}
		}

}
Esempio n. 21
0
	bool CDXUIManager::AddCheckBox(UINT id, float fX, float fY, float fSide, bool bChecked)
	{
		DXUIElement* pNew = AddElement(id);
		if (pNew)
		{
			CDXUICheckBox* pCheck = new CDXUICheckBox();
			if (FAILED(pCheck->Create(fX, fY, fSide, bChecked)))
			{
				DX_SAFE_DELETE(pCheck);
				RemoveElement(pNew);

				return false;
			}
			pCheck->m_pSprite = m_pSprite;
			pCheck->m_pUIManager = this;

			pNew->pElement = pCheck;
		}

		return true;
	}
Esempio n. 22
0
	bool CDXUIManager::AddScrollBar(UINT id, float fX, float fY, float fLength, UINT uiNumUnits, bool bVertical, float fThickness)
	{
		DXUIElement* pNew = AddElement(id);
		if (pNew)
		{
			CDXUIScrollBar* pScroll = new CDXUIScrollBar();
			if (FAILED(pScroll->Create(fX, fY, fLength, fThickness, uiNumUnits, bVertical)))
			{
				DX_SAFE_DELETE(pScroll);
				RemoveElement(pNew);

				return false;
			}

			pScroll->m_pUIManager = this;
			pScroll->m_pSprite = m_pSprite;

			pNew->pElement = pScroll;
		}

		return true;
	}
Esempio n. 23
0
	bool CDXUIManager::AddButton(UINT id, WCHAR* szCaption, float fX, float fY, float fWidth, float fHeight)
	{
		DXUIElement* pNew = AddElement(id);
		if (pNew)
		{
			CDXUIButton* pButton = new CDXUIButton();
			if (FAILED(pButton->Create(szCaption, fX, fY, fWidth, fHeight)))
			{
				DX_SAFE_DELETE(pButton);
				RemoveElement(pNew);

				return false;
			}

			pButton->m_pUIManager = this;
			pButton->m_pSprite = m_pSprite;

			pNew->pElement = pButton;
		}

		return true;
	}
Esempio n. 24
0
//=================================================================================================
void PickItemDialog::OnSelect()
{
	if(multiple == 0)
	{
		// single selection, return result
		result = BUTTON_OK;
		selected.push_back(flow.selected);
		GUI.CloseDialog(this);
		if(event)
			event(result);
	}
	else
	{
		// multiple selection
		FlowItem* item = flow.selected;
		if(item->state == Button::DOWN)
		{
			// remove selection
			item->state = Button::NONE;
			RemoveElement(selected, item);
		}
		else
		{
			// add selection
			item->state = Button::DOWN;
			selected.push_back(item);
			if(selected.size() == (uint)multiple)
			{
				// selected requested count of items, return result
				result = BUTTON_OK;
				GUI.CloseDialog(this);
				if(event)
					event(result);
			}
		}
	}
}
Esempio n. 25
0
void CMouse::OnElementGetsInvisible(Element *pChild)
	{
	// clear ptr
	RemoveElement(pChild);
	}
Esempio n. 26
0
void DestroyList(LinkedList *listPtr)
{
	while(RemoveElement(listPtr,0));
}
Esempio n. 27
0
void CGraphicsContainer::MoveElementToGroup(IElementPtr pElement, CGroupElementPtr pGroupElement)
{
	RemoveElement(pElement);

	pGroupElement->Add(pElement);
}
Esempio n. 28
0
void
ImportLoader::RemoveLinkElement(nsINode* aNode)
{
  mLinks.RemoveElement(aNode);
}
Esempio n. 29
0
static void OnCommand (HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
   LPAUDITDBPARAMS lpauditdb = GetDlgProp (hwnd);
   BOOL Success;

   switch (id)
   {
       case IDOK:
           if (lpauditdb->bStartSinceTable)
           {
             char szTblOwner[MAXOBJECTNAME];
             OwnerFromString(table.lpTable->lpObject, szTblOwner);
             if ( IsTheSameOwner(GetCurMdiNodeHandle(),szTblOwner) == FALSE )
               break;
             if ( table.bRefuseTblWithDupName && IsTableNameUnique(GetCurMdiNodeHandle(),lpauditdb->DBName,table.lpTable->lpObject) == FALSE)
               break;
           }
           Success = FillStructureFromControls (hwnd);

           if (!Success)
               break;
           else
           {
               FreeObjectList (table.lpTable);
               table.lpTable = NULL;
               lpfile = FreeTableAndFile (lpfile);
               EndDialog (hwnd, TRUE);
           }
           break;

       case IDCANCEL:
           FreeObjectList (table.lpTable);
           table.lpTable = NULL;
           lpfile = FreeTableAndFile (lpfile);

           EndDialog (hwnd, FALSE);
           break;

       case IDC_AUDITDB_CKP:
           EnableDisableControls (hwnd);
           break;

       case IDC_AUDITDB_CKP_BUTTON:
           {
               char szCurChkPtNum[MAXOBJECTNAME];
               char szUserName    [MAXOBJECTNAME];
               int ires;
               LPUCHAR vnodeName = GetVirtNodeName (GetCurMdiNodeHandle ());

               DBAGetUserName (GetVirtNodeName ( GetCurMdiNodeHandle ()), szUserName);
               ires = MfcDlgCheckPointLst(lpauditdb->DBName ,szUserName, vnodeName, szCurChkPtNum);
               if (ires != IDCANCEL)
                   Edit_SetText   (GetDlgItem (hwnd, IDC_AUDITDB_CKP_NUMBER), szCurChkPtNum);
               break;
           }
       case IDC_AUDITDB_IDTABLE:
           {
               int   iret;
               char* aString;
               char  szTable [MAXOBJECTNAME];
               LPOBJECTLIST ls;
               LPTABLExFILE lf;

               x_strcpy (table.DBName,  lpauditdb->DBName);
               table.bRefuseTblWithDupName = TRUE;
               iret = DlgAuditDBTable (hwnd, &table);

               ls = table.lpTable;
               EnableDisableControls (hwnd);

               while (ls)
               {
                   aString = (char *)ls->lpObject;
                   if (!FindStringInListTableAndFile (lpfile, aString))
                   {
                       //
                       // Add table  into TABLExFILE
                       //
                       lpfile = AddElement (lpfile, aString);
                   }
                   ls = ls->lpNext;
               }
               AddFile (hwnd, lpfile);

               lf = lpfile;
               while (lf)
               {
                   if (!FindStringInListObject (table.lpTable, lf->TableName))
                   {
                       //
                       // Delete table from TABLExFILE
                       //
                       x_strcpy (szTable, lf->TableName);
                       lf = lf->next;
                       lpfile = RemoveElement (lpfile, szTable);
                   }
                   else lf = lf->next;
               }
           }
           break;

       case IDC_AUDITDB_IDFILE:
           {
               int iret;
               AUDITDBFPARAMS file;
               ZEROINIT (file);

               x_strcpy (file.DBName,  lpauditdb->DBName);
               file.lpTableAndFile = lpfile;
               iret   = DlgAuditDBFile (hwnd, &file);
               if (iret)
                   lpfile = file.lpTableAndFile;
           }
           break;

       case IDC_AUDITDB_TABLES:
           EnableDisableControls (hwnd);
           break;
       case IDC_AUDITDB_FILES:
           EnableDisableControls (hwnd);
           break;
   }
}
Esempio n. 30
0
void CTerrain::Delete()
{
	RemoveElement(listter, this);
}