本文整理汇总了C++中property::Map::Merge方法的典型用法代码示例。如果您正苦于以下问题:C++ Map::Merge方法的具体用法?C++ Map::Merge怎么用?C++ Map::Merge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类property::Map
的用法示例。
在下文中一共展示了Map::Merge方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UtcDaliPropertyMapMerge
int UtcDaliPropertyMapMerge(void)
{
Property::Map map;
map[ "hello" ] = 1;
map[ "world" ] = 2;
DALI_TEST_CHECK( map.Count() == 2 );
// Create another map with the same keys but different values
Property::Map map2;
map[ "hello" ] = 3;
map[ "world" ] = 4;
// Merge map2 into map1, count should still be 2, map values should be from map2
map.Merge( map2 );
DALI_TEST_CHECK( map.Count() == 2 );
DALI_TEST_CHECK( map[ "hello" ].Get< int >() == 3 );
DALI_TEST_CHECK( map[ "world"].Get< int >() == 4 );
// Create another map with different keys
Property::Map map3;
map3[ "foo" ] = 5;
map3[ "bar" ] = 6;
// Merge map3 into map1, count should increase, existing values should match previous and new values should match map3
map.Merge( map3 );
DALI_TEST_CHECK( map.Count() == 4 );
DALI_TEST_CHECK( map[ "hello" ].Get< int >() == 3 );
DALI_TEST_CHECK( map[ "world"].Get< int >() == 4 );
DALI_TEST_CHECK( map[ "foo"].Get< int >() == 5 );
DALI_TEST_CHECK( map[ "bar"].Get< int >() == 6 );
// Create an empty map and attempt to merge, should be successful, nothing should change
Property::Map map4;
DALI_TEST_CHECK( map4.Empty() );
map.Merge( map4 );
DALI_TEST_CHECK( map4.Empty() );
DALI_TEST_CHECK( map.Count() == 4 );
DALI_TEST_CHECK( map[ "hello" ].Get< int >() == 3 );
DALI_TEST_CHECK( map[ "world"].Get< int >() == 4 );
DALI_TEST_CHECK( map[ "foo"].Get< int >() == 5 );
DALI_TEST_CHECK( map[ "bar"].Get< int >() == 6 );
// Merge map into map4, map4 should be the same as map now.
map4.Merge( map );
DALI_TEST_CHECK( map4.Count() == 4 );
DALI_TEST_CHECK( map4[ "hello" ].Get< int >() == 3 );
DALI_TEST_CHECK( map4[ "world"].Get< int >() == 4 );
DALI_TEST_CHECK( map4[ "foo"].Get< int >() == 5 );
DALI_TEST_CHECK( map4[ "bar"].Get< int >() == 6 );
// Attempt to merge into itself, should be successful, nothing should change
map.Merge( map );
DALI_TEST_CHECK( map.Count() == 4 );
DALI_TEST_CHECK( map[ "hello" ].Get< int >() == 3 );
DALI_TEST_CHECK( map[ "world"].Get< int >() == 4 );
DALI_TEST_CHECK( map[ "foo"].Get< int >() == 5 );
DALI_TEST_CHECK( map[ "bar"].Get< int >() == 6 );
END_TEST;
}