Index.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef _Index_h_
  2. #define _Index_h_
  3. /* Index.h
  4. *
  5. * Copyright (C) 2005-2011, 2016-2017 David Weenink
  6. *
  7. * This code is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * This code is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this work. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include "Collection.h"
  21. #include "Index_def.h"
  22. /*
  23. * An Index is a summary of an array of strings.
  24. * It has two parts:
  25. * 1 an OrderedSet of the different strings that occur
  26. * 2 an item array with indexes in this OrderedSet
  27. * Example:
  28. * Suppose we have a Strings with 7 elements/items "u", "o", "a", "u", "u", "o", "a"
  29. * The Index derived from this Strings will have 3 elements in its sorted set "a", "o" and "u"
  30. * The item array with indices will have the following content: 3, 2, 1, 3, 3, 2, 1
  31. */
  32. void Index_init (Index me, integer numberOfElements);
  33. autoIndex Index_extractPart (Index me, integer from, integer to);
  34. integer Index_getClassIndexFromItemIndex (Index me, integer itemIndex);
  35. autoStringsIndex StringsIndex_create (integer numberOfItems);
  36. int StringsIndex_getClassIndexFromClassLabel (StringsIndex me, conststring32 classLabel);
  37. conststring32 StringsIndex_getClassLabelFromClassIndex (StringsIndex me, integer classNumber);
  38. conststring32 StringsIndex_getItemLabelFromItemIndex (StringsIndex me, integer itemNumber);
  39. integer StringsIndex_countItems (StringsIndex me, int iclas);
  40. #endif /* _Index_h_ */