Helix Core is now P4. Product user interfaces will be updated soon. Learn more >>

C/C++ API Documentation | 2025.2

# MapApi::Count()

Returns the number of entries currently in the mapping.

Virtual? | No |
Class | `MapApi` |
Arguments | None |
Returns | `int` | The number of entries currently in the mapping

## Notes

The number returned by `Count()` might be different from the number of times that `Insert()` has been called. This is because `MapApi` automatically disambiguates itself, adding new exclusions to eliminate ambiguity between partially overlapping entries and removing entries that are redundant.

## Example

The following example demonstrates `Count()`, `GetType()`, `GetLeft()`, and `GetRight()` being used to iterate over a `MapApi` that contains four entries after two calls to `Insert()`.

This code produces the following output:

    //depot/... //client/...
    -//depot/d2/... //client/d2/...
    -//depot/d1/... //client/d1/...
    //depot/d1/... //client/d2/...

    MapApi clientmap;

    clientmap.Insert( StrRef( "//depot/..." ), StrRef( "//client/..." ) );
    clientmap.Insert( StrRef( "//depot/d1/..." ), StrRef( "//client/d2/..." ) );

    char c = ' ';
    for ( int i = 0; i < clientmap.Count(); i++ )
    {
        switch( clientmap.GetType( i ) )
        {
            case MapInclude:
                c = ' '; break;
            case MapExclude:
                c = '-'; break;
            case MapOverlay:
                c = '+'; break;
        }

        printf( "%c%s %s\n", c,
                clientmap.GetLeft( i )->Text(),
                clientmap.GetRight( i )->Text() );
    }

Your search for returned results