MyGUI 3.5.3
MyGUI_BiIndexBase.h
Go to the documentation of this file.
1/*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7#ifndef MYGUI_BIINDEX_BASE_H_
8#define MYGUI_BIINDEX_BASE_H_
9
10#include "MyGUI_Prerequest.h"
11#include <vector>
12#include <stddef.h>
13
14namespace MyGUI
15{
16
17 class MYGUI_EXPORT BiIndexBase
18 {
19 public:
20 virtual ~BiIndexBase() = default;
21
22 protected:
23 size_t getIndexCount() const;
24
25 size_t insertItemAt(size_t _index);
26
27 size_t removeItemAt(size_t _index);
28
29 void removeAllItems();
30
31 // Convert from user-facing index to actual data index
32 size_t convertToBack(size_t _index) const;
33
34 // Convert from actual data index to user-facing index
35 size_t convertToFace(size_t _index) const;
36
37 // Swap two items by user-facing indices
38 void swapItemsFaceAt(size_t _index1, size_t _index2);
39
40 // Swap two items by actual data indices
41 void swapItemsBackAt(size_t _index1, size_t _index2);
42
43 void checkIndexes();
44
45 private:
46 using VectorSizeT = std::vector<size_t>;
47
48 // Mapping from user-facing indices to actual data indices
49 VectorSizeT mIndexFace;
50
51 // Mapping from actual data indices to user-facing indices
52 // to user-visible indices
53 VectorSizeT mIndexBack;
54 };
55
56} // namespace MyGUI
57
58#endif // MYGUI_BIINDEX_BASE_H_
#define MYGUI_EXPORT