Tizen 2.0
От: enji  
Дата: 19.02.13 16:34
Оценка: :))) :))) :))
Стащил у eao197.

Будущее мобильной разработки, Tizen 2.0. По моему, шикарно... 6 new, 3 каста, 1 delete и даже E_SUCCESS
    void
    MyClass::HashMapSample(void)
    {
        HashMap map(SingleObjectDeleter);

        // Constructs a %HashMap instance with default capacity, load factor, hash code provider, and comparer
        map.Construct();

        map.Add(new String(L"Zero"), new Integer(0));       // map.GetCount() : 1, map : (Zero -> 0)
        map.Add(new String(L"One"), new Integer(1));        // map.GetCount() : 2, map : (Zero -> 0), (one -> 1)
        map.Add(new String(L"Two"), new Integer(2));        // map.GetCount() : 3, map : (Zero -> 0), (one -> 1), (Two -> 2)

        // Gets a value with the specified key
        Integer*    pValue = static_cast< Integer* > (map.GetValue(String(L"Zero")));       // pValue : 0

        // Removes the value with the specified key
        map.Remove(String(L"Zero"));                                            // map.GetCount() : 2, map : (one -> 1), (Two -> 2)

        // Uses an enumerator to access elements in the list
        IMapEnumerator* pMapEnum = map.GetMapEnumeratorN();
        String* pKey = null;
        while (pMapEnum->MoveNext() == E_SUCCESS)
        {
            pKey = static_cast< String* > (pMapEnum->GetKey());
            pValue = static_cast< Integer* > (pMapEnum->GetValue());
        }

        delete pMapEnum;

        // Deallocates all objects
        // Because the destructor calls RemoveAll() internally, you don't need to call RemoveAll() to destroy all elements at the end.
        map.RemoveAll();

    }


01.03.13 13:58: Перенесено модератором из 'C/C++'. Извините, но размер дискуссии говорит за себя. — Кодт
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.