Ejemplo n.º 1
0
/// Function name  : findDocumentIndexByValue
// Description     : Determines the index of the specified document
// 
// DOCUMENTS_DATA*  pDocumentsData  : [in]  Window data
// CONST DOCUMENT*  pTargetDocument : [in]  Document to retrieve the index for
// INT&             iOutput         : [out] Zero-based index if found, otherwise -1
// 
// Return Value   : TRUE if found, otherwise FALSE
// 
BOOL   findDocumentIndexByValue(DOCUMENTS_DATA*  pWindowData, CONST DOCUMENT*  pTargetDocument, INT&  iOutput)
{
   LIST_ITERATOR*  pIterator;             // List iterator
   DOCUMENT*       pCurrentDocument;      // List iterator

   
   // Prepare
   iOutput = -1;

   /// Iterate through document list
   for (pIterator = createListIterator(pWindowData->pDocumentList); getCurrentItem(pIterator, (LPARAM&)pCurrentDocument); moveNextItem(pIterator))
   {
      // [CHECK] Compare current item
      if (pCurrentDocument == pTargetDocument)
      {
         /// [FOUND] Set result and abort
         iOutput = pIterator->iIndex;
         break;
      }
   }

   // Cleanup and return TRUE if found
   deleteListIterator(pIterator);
   return (iOutput != -1);
}
Ejemplo n.º 2
0
/// Function name  : findDocumentIndexByPath
// Description     : Determines the index of the specified document
// 
// HWND          hTabCtrl     : [in]  Documents control
// CONST TCHAR*  szFullPath   : [in]  Full path of the desired document
// INT&          iOutput      : [out] Zero-based index if found, otherwise -1
// 
// Return Value   : TRUE if found, otherwise FALSE
// 
BOOL   findDocumentIndexByPath(HWND  hTabCtrl, CONST TCHAR*  szFullPath, INT&  iOutput)
{
   DOCUMENTS_DATA* pWindowData;    // Window data
   LIST_ITERATOR*  pIterator;      // List iterator
   DOCUMENT*       pDocument;      // List iterator

   
   // Prepare
   pWindowData = getDocumentsControlData(hTabCtrl);
   iOutput     = -1;
   
   /// Iterate through document list
   for (pIterator = createListIterator(pWindowData->pDocumentList); getCurrentItem(pIterator, (LPARAM&)pDocument); moveNextItem(pIterator))
   {
      // [CHECK] Compare paths
      if (utilCompareStringVariables(getDocumentPath(pDocument), szFullPath))
      {
         /// [FOUND] Set result and abort
         iOutput = pIterator->iIndex;
         break;
      }
   }

   // Cleanup and return TRUE if found
   deleteListIterator(pIterator);
   return (iOutput != -1);
}
Ejemplo n.º 3
0
void llsort(linkedlist_t* list, int(*comp)(const void*, const void*)){
	int i = 0;
	listiterator_t* iter = (listiterator_t*)0;
	data_entry_t *arr = lltoArray(list);
	qsort(&arr[0], list->size, sizeof(data_entry_t), comp);
	iter = createListIterator(list, 0);
	for(;i<list->size; ++i){
		linext(iter);
		liset(iter, arr[i].data, arr[i].nBytes);
	}
	destroyListIterator(iter);
	free(arr);

}