本文整理汇总了C++中Array::Back方法的典型用法代码示例。如果您正苦于以下问题:C++ Array::Back方法的具体用法?C++ Array::Back怎么用?C++ Array::Back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Array
的用法示例。
在下文中一共展示了Array::Back方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateObject
//==================================
// VRMenuMgrLocal::CreateObject
// creates a new menu object
menuHandle_t VRMenuMgrLocal::CreateObject( VRMenuObjectParms const & parms )
{
if ( !Initialized )
{
LOG( "VRMenuMgrLocal::CreateObject - manager has not been initialized!" );
return menuHandle_t();
}
// validate parameters
if ( parms.Type >= VRMENU_MAX )
{
LOG( "VRMenuMgrLocal::CreateObject - Invalid menu object type: %i", parms.Type );
return menuHandle_t();
}
// create the handle first so we can enforce setting it be requiring it to be passed to the constructor
int index = -1;
if ( FreeList.GetSizeI() > 0 )
{
index = FreeList.Back();
FreeList.PopBack();
}
else
{
index = ObjectList.GetSizeI();
}
UInt32 id = ++CurrentId;
menuHandle_t handle = ComposeHandle( index, id );
//LOG( "VRMenuMgrLocal::CreateObject - handle is %llu", handle.Get() );
VRMenuObject * obj = new VRMenuObjectLocal( parms, handle );
if ( obj == NULL )
{
LOG( "VRMenuMgrLocal::CreateObject - failed to allocate menu object!" );
OVR_ASSERT( obj != NULL ); // this would be bad -- but we're likely just going to explode elsewhere
return menuHandle_t();
}
obj->Init( parms );
if ( index == ObjectList.GetSizeI() )
{
// we have to grow the array
ObjectList.PushBack( obj );
}
else
{
// insert in existing slot
OVR_ASSERT( ObjectList[index] == NULL );
ObjectList[index ] = obj;
}
return handle;
}
示例2: HandleEvents
//==============================
// VRMenuEventHandler::HandleEvents
void VRMenuEventHandler::HandleEvents( OvrGuiSys & guiSys, VrFrame const & vrFrame,
menuHandle_t const rootHandle, Array< VRMenuEvent > const & events ) const
{
VRMenuObject * root = guiSys.GetVRMenuMgr().ToObject( rootHandle );
if ( root == NULL )
{
return;
}
// find the list of all objects that are in the focused path
Array< menuHandle_t > focusPath;
FindTargetPath( guiSys, rootHandle, FocusedHandle, focusPath );
Array< menuHandle_t > targetPath;
for ( int i = 0; i < events.GetSizeI(); ++i )
{
VRMenuEvent const & event = events[i];
switch ( event.DispatchType )
{
case EVENT_DISPATCH_BROADCAST:
{
// broadcast to everything
BroadcastEvent( guiSys, vrFrame, event, root );
}
break;
case EVENT_DISPATCH_FOCUS:
// send to the focus path only -- this list should be parent -> child order
DispatchToPath( guiSys, vrFrame, event, focusPath, false );
break;
case EVENT_DISPATCH_TARGET:
if ( targetPath.GetSizeI() == 0 || event.TargetHandle != targetPath.Back() )
{
targetPath.Clear();
FindTargetPath( guiSys, rootHandle, event.TargetHandle, targetPath );
}
DispatchToPath( guiSys, vrFrame, event, targetPath, false );
break;
default:
OVR_ASSERT( !"unknown dispatch type" );
break;
}
}
}