1/****************************************************************************************
2
3 Copyright (C) 2015 Autodesk, Inc.
4 All rights reserved.
5
6 Use of this software is subject to the terms of the Autodesk license agreement
7 provided at the time of installation or download, or which otherwise accompanies
8 this software in either electronic or hard copy form.
9
10****************************************************************************************/
11
12//! \file fbxmultimap.h
13#ifndef _FBXSDK_CORE_BASE_MULTIMAP_H_
14#define _FBXSDK_CORE_BASE_MULTIMAP_H_
15
16#include <fbxsdk/fbxsdk_def.h>
17
18#include <fbxsdk/fbxsdk_nsbegin.h>
19
20/** Class to manipulate a map that can contain multiple times the same key.
21* \nosubgrouping */
22class FBXSDK_DLL FbxMultiMap
23{
24public:
25 struct Pair
26 {
27 FbxHandle mKey;
28 FbxHandle mItem;
29 };
30
31 /** If can't find the matching item,append a item at the end of the array.
32 * If find the matching item ,insert the new item before the matching item.
33 * \param pKey The value of Key in new item, also is the character for matching.
34 * \param pItem The value of Item in new item.
35 * \return If add successfully return true,otherwise return false.
36 */
37 bool Add(FbxHandle pKey, FbxHandle pItem);
38
39 /** Remove the first matching item, whose reference is the same as given.
40 * \param pKey The given reference.
41 * \return If remove successfully return true,otherwise return false.
42 */
43 bool Remove(FbxHandle pKey);
44
45 /** Remove all the matching item, whose item is the same as given.
46 * \param pItem The given item.
47 * \return If remove successfully return true,otherwise return false.
48 */
49 bool RemoveItem(FbxHandle pItem);
50
51 /** Set first matching item with the given parameter.
52 * \param pKey The character for matching.
53 * \param pItem The value of Item that the matching item will be set.
54 * \return If set successfully return true,otherwise return false.
55 */
56 bool SetItem(FbxHandle pKey, FbxHandle pItem);
57
58 /** Get first matching item with the given parameter.
59 * \param pKey The character for matching.
60 * \param pIndex The pointer to the index of the matching item.
61 * \return The value of Item in the matching item.
62 * \remarks If there are multiple elements that match the character, the index returned is unspecified.
63 */
64 FbxHandle Get(FbxHandle pKey, int* pIndex=NULL);
65
66 //! Delete the array.
67 void Clear();
68
69 /** Get the item of the given index.
70 * \param pIndex The index for matching.
71 * \param pKey The pointer to the Key of the matching item.
72 * \return The value of Item in the matching item.
73 */
74 FbxHandle GetFromIndex(int pIndex, FbxHandle* pKey=NULL);
75
76 /** Remove the item of the given index
77 * \param pIndex The given index.
78 * \return If remove successfully return true,otherwise return false.
79 */
80 bool RemoveFromIndex(int pIndex);
81
82 /** Get number of items in the array.
83 * \return The number of items in the array. */
84 int GetCount() const { return mSetCount; }
85
86 /** Swap the value of Key and Item in every item of array, and sort the new array with the value of Key. */
87 void Swap();
88
89 /** Sort the array according the value of Key in each item. */
90 void Sort();
91
92/*****************************************************************************************************************************
93** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
94*****************************************************************************************************************************/
95#ifndef DOXYGEN_SHOULD_SKIP_THIS
96 FbxMultiMap(int pItemPerBlock=20);
97 FbxMultiMap(const FbxMultiMap& pOther);
98 ~FbxMultiMap();
99
100 FbxMultiMap& operator=(const FbxMultiMap&);
101
102private:
103 Pair* FindEqual(FbxHandle pKey) const;
104
105 Pair* mSetArray;
106 int mSetCount;
107 int mBlockCount;
108 int mItemPerBlock;
109 bool mIsChanged;
110#endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
111};
112
113#include <fbxsdk/fbxsdk_nsend.h>
114
115#endif /* _FBXSDK_CORE_BASE_MULTIMAP_H_ */
116