Search This Blog

Friday, July 6, 2012

Copy Map


This code is just you can add into global and you can use int any where in your logics for creating map from another map

static Map CopyMap(Map _mapFrom, Map _mapTo)
{
    MapEnumerator   mapEnumerator;
    ;
    if (_mapFrom && _mapTo)
    {
        mapEnumerator = _mapFrom.getEnumerator();
        while (mapEnumerator.moveNext())
        {
            if (_mapTo.exists(mapEnumerator.currentKey()))
            {
                _mapTo.insert(mapEnumerator.currentKey(), _mapTo.lookup(mapEnumerator.currentKey()) + mapEnumerator.currentValue());
            }
            else
            {
                _mapTo.insert(mapEnumerator.currentKey(), mapEnumerator.currentValue());
            }
        }
    }
    else
    {
        if (!_mapTo)
        {
            _mapTo = _mapFrom;
        }
    }

    return _mapTo;
}

No comments:

Post a Comment

Thanks for visiting my blog,
I will reply for your comment within 48 hours.

Thanks,
krishna.