arrayutils.tex 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. \chapter{TArrayUtils}
  2. Set of utilities for manipulating arrays data.
  3. Takes 3 arguements for specialization. First one is type of array (can be anything, which is
  4. accesible by [] operator, e. g. ordinary array, vector, ...), second one is type of array element.
  5. %Usage example for sorting:
  6. %\lstinputlisting[language=Pascal]{sortingexample.pp}
  7. Members list:
  8. \begin{longtable}{|m{10cm}|m{5cm}|}
  9. \hline
  10. Method & Complexity guarantees \\ \hline
  11. \multicolumn{2}{|m{15cm}|}{Description} \\ \hline\hline
  12. \verb!procedure RandomShuffle(arr: TArr, size:SizeUint)! &
  13. O(N)\\ \hline
  14. \multicolumn{2}{|m{15cm}|}{Shuffles elements in array in random way} \\\hline\hline
  15. \end{longtable}\chapter{TOrderingArrayUtils}
  16. Set of utilities for manipulating arrays data.
  17. Takes 3 arguements for specialization. First one is type of array (can be anything, which is
  18. accesible by [] operator, e. g. ordinary array, vector, ...), second one is type of array element,
  19. third one is comparator class (see TPriorityQueue for definition of comparator class).
  20. Usage example for sorting:
  21. \lstinputlisting[language=Pascal]{sortingexample.pp}
  22. Members list:
  23. \begin{longtable}{|m{10cm}|m{5cm}|}
  24. \hline
  25. Method & Complexity guarantees \\ \hline
  26. \multicolumn{2}{|m{15cm}|}{Description} \\ \hline\hline
  27. \verb!procedure Sort(arr: TArr, size:SizeUint)! &
  28. O(N log N) average and worst case. Uses QuickSort, backed up by HeapSort, when QuickSort ends up in
  29. using too much recursion.\\ \hline
  30. \multicolumn{2}{|m{15cm}|}{Sort array arr, with specified size. Array indexing should be 0 based.} \\\hline\hline
  31. \verb!function NextPermutation! \verb!(arr: TArr, size:SizeUint):boolean! &
  32. Worst case for one call $O(N)$. Going through all permutations takes $O(N!)$ time.\\ \hline
  33. \multicolumn{2}{|m{15cm}|}{Orders elements on indexes $0, 1, \dots, size-1$ into nearest
  34. lexikografic larger permutation.} \\\hline
  35. \end{longtable}