mirror of
https://github.com/Milxnor/Project-Reboot-3.0.git
synced 2026-01-13 02:42:22 +01:00
it kinda work
This commit is contained in:
@@ -30,35 +30,122 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
template <typename KeyType, typename ValueType> //, typename SetAllocator, typename KeyFuncs>
|
||||
class TMapBase
|
||||
template <typename KeyType, typename ValueType>
|
||||
class TMap
|
||||
{
|
||||
public:
|
||||
typedef TPair<KeyType, ValueType> ElementType;
|
||||
typedef TPair<KeyType, ValueType> ElementType;
|
||||
|
||||
typedef TSet<ElementType/*, KeyFuncs, SetAllocator */> ElementSetType;
|
||||
public:
|
||||
TSet<ElementType> Pairs;
|
||||
|
||||
ElementSetType Pairs;
|
||||
public:
|
||||
class FBaseIterator
|
||||
{
|
||||
private:
|
||||
TMap<KeyType, ValueType>& IteratedMap;
|
||||
TSet<ElementType>::FBaseIterator SetIt;
|
||||
|
||||
public:
|
||||
FBaseIterator(TMap<KeyType, ValueType>& InMap, TSet<ElementType>::FBaseIterator InSet)
|
||||
: IteratedMap(InMap)
|
||||
, SetIt(InSet)
|
||||
{
|
||||
}
|
||||
FORCEINLINE TMap<KeyType, ValueType>::FBaseIterator operator++()
|
||||
{
|
||||
++SetIt;
|
||||
return *this;
|
||||
}
|
||||
FORCEINLINE TMap<KeyType, ValueType>::ElementType& operator*()
|
||||
{
|
||||
return *SetIt;
|
||||
}
|
||||
FORCEINLINE const TMap<KeyType, ValueType>::ElementType& operator*() const
|
||||
{
|
||||
return *SetIt;
|
||||
}
|
||||
FORCEINLINE bool operator==(const TMap<KeyType, ValueType>::FBaseIterator& Other) const
|
||||
{
|
||||
return SetIt == Other.SetIt;
|
||||
}
|
||||
FORCEINLINE bool operator!=(const TMap<KeyType, ValueType>::FBaseIterator& Other) const
|
||||
{
|
||||
return SetIt != Other.SetIt;
|
||||
}
|
||||
FORCEINLINE bool IsElementValid() const
|
||||
{
|
||||
return SetIt.IsElementValid();
|
||||
}
|
||||
};
|
||||
|
||||
FORCEINLINE TMap<KeyType, ValueType>::FBaseIterator begin()
|
||||
{
|
||||
return TMap<KeyType, ValueType>::FBaseIterator(*this, Pairs.begin());
|
||||
}
|
||||
FORCEINLINE const TMap<KeyType, ValueType>::FBaseIterator begin() const
|
||||
{
|
||||
return TMap<KeyType, ValueType>::FBaseIterator(*this, Pairs.begin());
|
||||
}
|
||||
FORCEINLINE TMap<KeyType, ValueType>::FBaseIterator end()
|
||||
{
|
||||
return TMap<KeyType, ValueType>::FBaseIterator(*this, Pairs.end());
|
||||
}
|
||||
FORCEINLINE const TMap<KeyType, ValueType>::FBaseIterator end() const
|
||||
{
|
||||
return TMap<KeyType, ValueType>::FBaseIterator(*this, Pairs.end());
|
||||
}
|
||||
FORCEINLINE ValueType& operator[](const KeyType& Key)
|
||||
{
|
||||
return this->GetByKey(Key);
|
||||
}
|
||||
FORCEINLINE const ValueType& operator[](const KeyType& Key) const
|
||||
{
|
||||
return this->GetByKey(Key);
|
||||
}
|
||||
FORCEINLINE int32 Num() const
|
||||
{
|
||||
return Pairs.Num();
|
||||
}
|
||||
FORCEINLINE bool IsValid() const
|
||||
{
|
||||
return Pairs.IsValid();
|
||||
}
|
||||
FORCEINLINE bool IsIndexValid(int32 IndexToCheck) const
|
||||
{
|
||||
return Pairs.IsIndexValid(IndexToCheck);
|
||||
}
|
||||
FORCEINLINE bool Contains(const KeyType& ElementToLookFor) const
|
||||
{
|
||||
for (auto Element : *this)
|
||||
{
|
||||
if (Element.Key() == ElementToLookFor)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
FORCEINLINE ValueType& GetByKey(const KeyType& Key)
|
||||
{
|
||||
for (auto Pair : *this)
|
||||
{
|
||||
if (Pair.Key() == Key)
|
||||
{
|
||||
return Pair.Value();
|
||||
}
|
||||
}
|
||||
}
|
||||
FORCEINLINE ValueType& Find(const KeyType& Key)
|
||||
{
|
||||
for (int j = 0; j < this->Pairs.Elements.Num(); j++)
|
||||
return GetByKey(Key);
|
||||
}
|
||||
FORCEINLINE ValueType GetByKeyNoRef(const KeyType& Key)
|
||||
{
|
||||
for (auto Pair : *this)
|
||||
{
|
||||
ElementType& Pair = this->Pairs.Elements.operator[](j).ElementData.Value;
|
||||
|
||||
if (Key == Pair.Key())
|
||||
if (Pair.Key() == Key)
|
||||
{
|
||||
return Pair.Value();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename KeyType, typename ValueType> //, typename SetAllocator, typename KeyFuncs>
|
||||
class TSortableMapBase : public TMapBase<KeyType, ValueType> //, SetAllocator, KeyFuncs>
|
||||
{
|
||||
};
|
||||
|
||||
template<typename KeyType, typename ValueType> //,typename SetAllocator /*= FDefaultSetAllocator*/, typename KeyFuncs /*= TDefaultMapHashableKeyFuncs<KeyType,ValueType,false>*/>
|
||||
class TMap : public TSortableMapBase<KeyType, ValueType> //, SetAllocator, KeyFuncs>
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user