CCScrollView/CCSorting(。。)

#ifndef __CCSORTING_H__

#define __CCSORTING_H__


#include "cocoa/CCArray.h"

#include "ExtensionMacros.h"


NS_CC_EXT_BEGIN


class CCSortableObject

{

public:

    virtual ~CCSortableObject() {}

    virtual void setObjectID(unsigned int objectID) = 0;

    virtual unsigned int getObjectID() = 0;

};


class CCArrayForObjectSorting : public CCArray

{

public:

    CCArrayForObjectSorting() : CCArray() {}

    /*!

     * Inserts a given object into array.

     * 

     * Inserts a given object into array with key and value that are used in

     * sorting. "value" must respond to message, compare:, which returns 

     * (NSComparisonResult). If it does not respond to the message, it is appended.

     * If the compare message does not result NSComparisonResult, sorting behavior

     * is not defined. It ignores duplicate entries and inserts next to it.

     *

     * @param object to insert

     */

    void insertSortedObject(CCSortableObject* object);


    /*!

     * Removes an object in array.

     *

     * Removes an object with given key and value. If no object is found in array

     * with the key and value, no action is taken.

     *

     * @param value to remove

     */

    void removeSortedObject(CCSortableObject* object);

    /*!

     * Sets a new value of the key for the given object.

     * 

     * In case where sorting value must be changed, this message must be sent to

     * keep consistency of being sorted. If it is changed externally, it must be

     * sorted completely again.

     *

     * @param value to set

     * @param object the object which has the value

     */

    void setObjectID_ofSortedObject(unsigned int tag, CCSortableObject* object);


    CCSortableObject* objectWithObjectID(unsigned int tag);

    /*!

     * Returns an object with given key and value.

     * 

     * Returns an object with given key and value. If no object is found,

     * it returns nil.

     *

     * @param value to locate object

     * @return object found or nil.

     */

    CCSortableObject* getObjectWithObjectID(unsigned int tag);


    /*!

     * Returns an index of the object with given key and value.

     *

     * Returns the index of an object with given key and value. 

     * If no object is found, it returns an index at which the given object value

     * would have been located. If object must be located at the end of array,

     * it returns the length of the array, which is out of bound.

     * 

     * @param value to locate object

     * @return index of an object found

     */

    unsigned int indexOfSortedObject(CCSortableObject* obj);


};


NS_CC_EXT_END


#endif /* __CCSORTING_H__ */


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值