Search/moveToFront.c File Reference

Task to perform searches in unordered array and move to front when found. Load up an array of strings and perform number of unordered searches. No check for NULL is used. Move to Front of array on a successful find. More...

#include <malloc.h>
#include <string.h>
#include "report.h"

Functions

void construct (int n)
 Method to construct the initial search structure to contain 'sz' elements.
void insert (char *s)
 Method to insert an integer element into the search structure.
int search (char *target, int(*cmp)(const void *, const void *))
 Search for the target within the array.

Variables

static char ** ds
 Storage of string array.
static int dsSize
 Number of strings in the array 'ds'.
static int dsIdx
 Position into 'ds' into which the next string will be inserted.


Detailed Description

Task to perform searches in unordered array and move to front when found. Load up an array of strings and perform number of unordered searches. No check for NULL is used. Move to Front of array on a successful find.

Author:
George Heineman
Date:
6/15/08

Function Documentation

void construct ( int  n  ) 

Method to construct the initial search structure to contain 'sz' elements.

Allocate array of 'n' elements for 'ds'.

void insert ( char *  s  ) 

Method to insert an integer element into the search structure.

In our case, we insert the elements into a non-balancing tree.

Parameters:
s Value to be inserted.

int search ( char *  target,
int(*)(const void *, const void *)  cmp 
)

Search for the target within the array.

No Check for NULL. Move to Front when found via block moves.


Variable Documentation

char** ds [static]

Storage of string array.

int dsIdx [static]

Position into 'ds' into which the next string will be inserted.

int dsSize [static]

Number of strings in the array 'ds'.

Algorithm Development Kit 1.0