]>
cygwin.com Git - cygwin-apps/setup.git/blob - hash.cc
2 * Copyright (c) 2000, Red Hat, Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * A copy of the GNU General Public License can be found at
12 * Written by DJ Delorie <dj@cygnus.com>
16 /* Simple hash class for install.cc */
18 static char *cvsid
= "\n%%% $Id$\n";
25 class hash_internals
{
35 h
= new hash_internals
;
38 h
->keys
= (char **) malloc (h
->maxkeys
* sizeof (char *));
50 hash::add (char *string
)
53 for (i
=0; i
<h
->numkeys
; i
++)
54 if (strcmp (h
->keys
[i
], string
) == 0)
56 if (h
->numkeys
>= h
->maxkeys
)
59 h
->keys
= (char **) realloc (h
->keys
, h
->maxkeys
* sizeof (char *));
62 h
->keys
[h
->numkeys
] = _strdup (string
);
68 hash::has (char *string
)
71 for (i
=0; i
<h
->numkeys
; i
++)
72 if (strcmp (h
->keys
[i
], string
) == 0)
78 hash::enumerate (char *prev
)
83 if (h
->prev_index
>= h
->numkeys
)
85 return h
->keys
[h
->prev_index
];
89 rev_len (const void *va
, const void *vb
)
91 char *a
= *(char **)va
;
92 char *b
= *(char **)vb
;
99 qsort (h
->keys
, h
->numkeys
, sizeof (h
->keys
[0]), rev_len
);
This page took 0.039673 seconds and 5 git commands to generate.