]>
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 */
19 static const char *cvsid
=
39 h
= new hash_internals
;
42 h
->keys
= (char **) malloc (h
->maxkeys
* sizeof (char *));
54 hash::add (char const *string
)
57 for (i
= 0; i
< h
->numkeys
; i
++)
58 if (strcmp (h
->keys
[i
], string
) == 0)
60 if (h
->numkeys
>= h
->maxkeys
)
63 h
->keys
= (char **) realloc (h
->keys
, h
->maxkeys
* sizeof (char *));
66 h
->keys
[h
->numkeys
] = new char[strlen(string
) + 1];
67 strcpy (h
->keys
[h
->numkeys
], string
);
73 hash::has (char const *string
)
76 for (i
= 0; i
< h
->numkeys
; i
++)
77 if (strcmp (h
->keys
[i
], string
) == 0)
83 hash::enumerate (char const *prev
)
88 if (h
->prev_index
>= h
->numkeys
)
90 return h
->keys
[h
->prev_index
];
94 rev_len (const void *va
, const void *vb
)
96 char *a
= *(char **) va
;
97 char *b
= *(char **) vb
;
102 hash::reverse_sort ()
104 qsort (h
->keys
, h
->numkeys
, sizeof (h
->keys
[0]), rev_len
);
This page took 0.039487 seconds and 5 git commands to generate.