elementrarray.h

来自「series60 应用程序开发的源代码 series60 应用程序开发的源代码」· C头文件 代码 · 共 135 行

H
135
字号
#ifndef ELEMENTRARRAY_H
#define ELEMENTRARRAY_H

// INCLUDES

// System includes
#include <e32base.h>

// User includes
#include "elementlist.h"

// CLASS DECLARATION

/**
*
* @class    CElementCArray elementcarray.h
* @brief    Specialisation of CElementList to store list of CChemicalElements as a CArray
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*/

class CElementRArray : public CElementList
{
public:
    /**
    * Destructor
    */
    ~CElementRArray();

    /**
    * Default constructor--takes no arguments
    */
    CElementRArray();

    //From CElementList
public:
    /**
    * Getter for number of elements stored in the list
    * @return the number of elements stored in the list
    */
    TInt NumberOfElements() const;

    /**
    * Returns the element at the specified zero based index--const overload
    * @param aIndex The zero based index of the element required. Must be greater than zero, and less than
    * NumberOfElements()-1
    * @return A const reference to the element specified by aIndex
    * @panic KElementListPanicElementIndexOutOfRange if aIndex < 0 or aIndex > NumberOfElements()-1
    */
    const CChemicalElement& At(TInt aIndex) const;

    /**
    * Returns the element at the specified zero based index--non-const overload
    * @param aIndex The zero based index of the element required. Must be greater than zero, and less than
    * NumberOfElements()-1
    * @return A non-const (i.e. modifiable) reference to the element specified by aIndex
    * @panic KPanicElementIndexOutOfRange if aIndex < 0 or aIndex > NumberOfElements()-1
    */
    CChemicalElement& At(TInt aIndex);

    /**
    * Appends the given element onto the end of the list. Note that ownership of the element is passed to the
    * list, as denoted by the use of a CChemicalElement*.
    * @param aElement The element to be appended to the end of the list. Note its ownership is transferred, so
    * responsibility for aElement's destruction is no longer the responsibility of the caller.
    * @panic KElementListPanicNullElement If aElement==0
    */
    void AppendL(const CChemicalElement* aElement);

    /**
    * Deletes all of the elements owned by the list, and returns the memory allocated to them to the global heap.
    * Effectively resets the list to be empty.
    */
    void DeleteAllElements();

    /**
    * Searches the list for an element with name aName, and returns its zero-based index if found.
    * @param aName The name to search for.
    * @return The zero-based index of the element within the list.
    * @leave KErrNotFound If an element with name aName is not found.
    */
    TInt FindElementByNameL(const TDesC& aName) const;

    /**
    * Searches the list for an element with symbol aSymbol, and returns its zero-based index if found.
    * @param aSymbol The symbol to search for.
    * @return The zero-based index of the element within the list.
    * @leave KErrNotFound If an element with symbol aSymbol is not found.
    */
    TInt FindElementBySymbolL(const TDesC& aSymbol) const;

    /**
    * Searches the list for an element with atomic number aAtomicNumber, and returns its zero-based index if found.
    * @param aName The atomic number to search for.
    * @return The zero-based index of the element within the list.
    * @leave KErrNotFound If an element with atomic number aAtomicNumber is not found.
    */
    TInt FindElementByAtomicNumberL(TInt aAtomicNumber) const;

    /**
    * Re-orders the list in ascending name order (i.e. alphabetical by name)
    * @leave This implementation will not leave
    */
    void SortByNameL();

    /**
    * Re-orders the list in ascending symbol order (i.e. alphabetical by symbol)
    * @leave This implementation will not leave
    */
    void SortBySymbolL();

    /**
    * Re-orders the list in ascending atomic number order (i.e. smallest atomic number first)
    * @leave This implementation will not leave
    */
    void SortByAtomicNumberL();

    /**
    * Re-orders the list in ascending relative atomic mass order (i.e. lightest element first)
    * @leave This implementation will not leave
    */
    void SortByRelativeAtomicMassL();

private:
    TInt DoFindL(const TIdentityRelation<CChemicalElement>& aReleation, const TDesC& aName,
        const TDesC& aSymbol, TInt aAtomicNumber) const;

private:
    RPointerArray<CChemicalElement>        iElementArray;
};
#endif // #ifndef ELEMENTRARRAY_H
    
// End of File

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?