Sorting/FileBased/insertion.c File Reference

Define code to produce a file containing array of strings which are to be sorted. Implementation of file-based sorting algorithm, where input is stored on disk in a contiguous block of n*s bytes where n is the number of elements in the disk and s is the length of each one (no null-terminated values used to determine string length). More...

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

Functions

static void insert (FILE *strings, int loc, int s, char *saved, int(*cmp)(const long, const char *))
 Insert in-place, where value already exists in list at location loc.
void sortFile (FILE *strings, int n, int s, int(*cmp)(const long, const char *))
 Sort the given file of n elements (each of which is of size s) using given comparator function.


Detailed Description

Define code to produce a file containing array of strings which are to be sorted. Implementation of file-based sorting algorithm, where input is stored on disk in a contiguous block of n*s bytes where n is the number of elements in the disk and s is the length of each one (no null-terminated values used to determine string length).

Author:
George Heineman
Date:
6/15/08

Function Documentation

static void insert ( FILE *  strings,
int  loc,
int  s,
char *  saved,
int(*)(const long, const char *)  cmp 
) [static]

Insert in-place, where value already exists in list at location loc.

void sortFile ( FILE *  strings,
int  n,
int  s,
int(*)(const long, const char *)  cmp 
)

Sort the given file of n elements (each of which is of size s) using given comparator function.

Parameters:
strings File on disk containing n strings of size s.
n Number of strings in this file.
s The fixed size of the strings in the file.
cmp Special comparator function that compares string in memory (a2) against location on disk (long pos).

Algorithm Development Kit 1.0