HyperDbg Debugger
Loading...
Searching...
No Matches
OptimizationsExamples.c File Reference
#include "pch.h"

Macros

#define MAX_NUM_OF_ARRAY   10
 Maximum number of array for test cases.
 

Functions

VOID OptimizationExampleInsertionSortAndBinarySearch ()
 Example of using array management functions for insertion sort and binary search.
 

Macro Definition Documentation

◆ MAX_NUM_OF_ARRAY

#define MAX_NUM_OF_ARRAY   10

Maximum number of array for test cases.

Function Documentation

◆ OptimizationExampleInsertionSortAndBinarySearch()

VOID OptimizationExampleInsertionSortAndBinarySearch ( )

Example of using array management functions for insertion sort and binary search.

Returns
VOID
28{
29 UINT64 Arr[MAX_NUM_OF_ARRAY] = {0};
30 UINT32 NumberOfItems = 0;
31 UINT32 Index;
32
33 InsertionSortInsertItem(Arr, &NumberOfItems, MAX_NUM_OF_ARRAY, 12);
34 InsertionSortInsertItem(Arr, &NumberOfItems, MAX_NUM_OF_ARRAY, 11);
35 InsertionSortInsertItem(Arr, &NumberOfItems, MAX_NUM_OF_ARRAY, 13);
36 InsertionSortInsertItem(Arr, &NumberOfItems, MAX_NUM_OF_ARRAY, 5);
37 InsertionSortInsertItem(Arr, &NumberOfItems, MAX_NUM_OF_ARRAY, 6);
38 InsertionSortInsertItem(Arr, &NumberOfItems, MAX_NUM_OF_ARRAY, 8);
39
40 //
41 // Search for item equal to 15
42 //
43 BOOLEAN Result = BinarySearchPerformSearchItem(Arr, NumberOfItems, &Index, 15);
44
45 if (Result)
46 {
47 LogInfo("Index found: %d", Index);
48
49 InsertionSortDeleteItem(Arr, &NumberOfItems, Index);
50 }
51 else
52 {
53 LogInfo("Index not found!");
54 }
55
56 BinarySearchPrintArray(Arr, NumberOfItems);
57
58}
UCHAR BOOLEAN
Definition BasicTypes.h:39
unsigned __int64 UINT64
Definition BasicTypes.h:21
unsigned int UINT32
Definition BasicTypes.h:48
VOID BinarySearchPrintArray(UINT64 ArrayPtr[], UINT32 NumberOfItems)
A utility function to print an array of size NumberOfItems.
Definition BinarySearch.c:23
BOOLEAN BinarySearchPerformSearchItem(UINT64 ArrayPtr[], UINT32 NumberOfItems, UINT32 *ResultIndex, UINT64 Key)
A utility function to perform the binary search.
Definition BinarySearch.c:46
#define LogInfo(format,...)
Define log variables.
Definition HyperDbgHyperLogIntrinsics.h:71
BOOLEAN InsertionSortDeleteItem(UINT64 ArrayPtr[], UINT32 *NumberOfItems, UINT32 Index)
Function to implement insertion sort.
Definition InsertionSort.c:66
BOOLEAN InsertionSortInsertItem(UINT64 ArrayPtr[], UINT32 *NumberOfItems, UINT32 MaxNumOfItems, UINT64 Key)
Function to implement insertion sort.
Definition InsertionSort.c:24
#define MAX_NUM_OF_ARRAY
Maximum number of array for test cases.
Definition OptimizationsExamples.c:18