mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Add a 'sort' function to an STArray. They can be used in cases where
order is significant or where they're sorted.
This commit is contained in:
@@ -866,6 +866,11 @@ STArray* STArray::construct(SerializerIterator& sit, SField::ref field)
|
||||
return new STArray(field, value);
|
||||
}
|
||||
|
||||
void STArray::sort(bool (*compare)(const STObject&, const STObject&))
|
||||
{
|
||||
std::sort(value.begin(), value.end(), compare);
|
||||
}
|
||||
|
||||
std::auto_ptr<STObject> STObject::parseJson(const Json::Value& object, SField::ref inName, int depth)
|
||||
{
|
||||
if (!object.isObject())
|
||||
|
||||
@@ -152,9 +152,9 @@ class STArray : public SerializedType
|
||||
{
|
||||
public:
|
||||
typedef std::vector<STObject> vector;
|
||||
typedef std::vector<STObject>::iterator iterator;
|
||||
typedef std::vector<STObject>::iterator iterator;
|
||||
typedef std::vector<STObject>::const_iterator const_iterator;
|
||||
typedef std::vector<STObject>::reverse_iterator reverse_iterator;
|
||||
typedef std::vector<STObject>::reverse_iterator reverse_iterator;
|
||||
typedef std::vector<STObject>::const_reverse_iterator const_reverse_iterator;
|
||||
typedef std::vector<STObject>::size_type size_type;
|
||||
|
||||
@@ -205,6 +205,8 @@ public:
|
||||
virtual Json::Value getJson(int) const;
|
||||
virtual void add(Serializer& s) const;
|
||||
|
||||
void sort(bool (*compare)(const STObject& o1, const STObject& o2));
|
||||
|
||||
bool operator==(const STArray &s) { return value == s.value; }
|
||||
bool operator!=(const STArray &s) { return value != s.value; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user