本文整理汇总了C++中Root函数的典型用法代码示例。如果您正苦于以下问题:C++ Root函数的具体用法?C++ Root怎么用?C++ Root使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Root函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LogicError
void
AbstractDistMatrix<T>::MakeSizeConsistent( bool includingViewers )
{
DEBUG_CSE
const Int msgSize = 2;
Int message[msgSize];
if( CrossRank() == Root() )
{
message[0] = height_;
message[1] = width_;
}
const auto& g = *grid_;
if( !g.InGrid() && !includingViewers )
LogicError("Non-participating process called MakeSizeConsistent");
if( g.InGrid() )
mpi::Broadcast( message, msgSize, Root(), CrossComm() );
if( includingViewers )
{
const Int vcRoot = g.VCToViewing(0);
mpi::Broadcast( message, msgSize, vcRoot, g.ViewingComm() );
}
const Int newHeight = message[0];
const Int newWidth = message[1];
Resize( newHeight, newWidth );
}
示例2: message
void GameState::onHandleEvent(sf::Event& event) {
if(event.type == sf::Event::KeyPressed) {
if(Root().debug) {
if(event.key.code == sf::Keyboard::Period) {
m_debugDrawEnabled = !m_debugDrawEnabled;
message("Debug draws toggled");
} else if(event.key.code == sf::Keyboard::Comma) {
m_shadersEnabled = !m_shadersEnabled;
message("Shaders toggled.");
} else if(event.key.code == sf::Keyboard::Q) {
m_player->setAbility((Player::Ability)(((int)m_player->getAbility() + 1) % ((int)Player::RAPPEL + 1)));
message("Ability: " + std::to_string(m_player->getAbility()));
} else if(event.key.code == sf::Keyboard::Escape) {
Root().window->close();
} else if(event.key.code == sf::Keyboard::Add) {
switchLevel(m_currentLevel + 1);
} else if(event.key.code == sf::Keyboard::Subtract) {
switchLevel(m_currentLevel - 1);
} else if(event.key.code == sf::Keyboard::H) {
m_currentHelp = m_levelHelp[m_currentLevelName];
} else if(event.key.code == sf::Keyboard::Tab) {
Root().states.push(&Root().editor_state);
if(m_player) m_player->m_walkSound.pause();
}
} else {
if(event.key.code == sf::Keyboard::Escape) {
Root().states.pop();
}
}
} else if(event.type == sf::Event::Resized) {
resize();
}
}
示例3: main
int main(int argc, char **argv)
{
CSTree T;
TElemType e;
TElemType e1;
InitTree(&T);
printf("构造空树后,树空否? %d(1:是 0:否) 树根为%c 树的深度为%d\n",\
TreeEmpty(T), Root(T), TreeDepth(T));
CreateTree(&T);
printf("构造空树后,树空否? %d(1:是 0:否) 树根为%c 树的深度为%d\n",\
TreeEmpty(T), Root(T), TreeDepth(T));
printf("先根遍历树T:\n");
PreOrderTraverse(T, vi);
printf("\n请输入等修改的结点的值 新值:");
scanf("%c%*c%c%*c", &e, &e1);
Assign(&T, e, e1);
printf("后根遍历修改后的树T:\n");
PostOrderTraverse_recurssion1(T, vi);
printf("\n");
printf("PostOrderTraverse_recurssion1 complete!\n");
PostOrderTraverse_recurssion2(T, vi);
printf("\n");
printf("PostOrderTraverse_recurssion2 complete!\n");
printf("\n%c的双亲是%c, 长子是%c,下一个兄弟是%c\n", e1, Parent(T, e1),\
LeftChild(T, e1), RightSibling(T, e1));
printf("层序遍历树:\n");
LevelOrderTraverse(T, vi);
DestroyTree(&T);
return EXIT_SUCCESS;
}
示例4: main
void main()
{
int i;
PTree T,p;
TElemType e,e1;
InitTree(T);
printf("构造空树后,树空否? %d(1:是 0:否) 树根为%c 树的深度为%d\n",TreeEmpty(T),Root(T),TreeDepth(T));
CreateTree(T);
printf("构造树T后,树空否? %d(1:是 0:否) 树根为%c 树的深度为%d\n",TreeEmpty(T),Root(T),TreeDepth(T));
printf("层序遍历树T:\n");
TraverseTree(T,vi);
printf("请输入待修改的结点的值 新值: ");
scanf("%c%*c%c%*c",&e,&e1);
Assign(T,e,e1);
printf("层序遍历修改后的树T:\n");
TraverseTree(T,vi);
printf("%c的双亲是%c,长子是%c,下一个兄弟是%c\n",e1,Parent(T,e1),LeftChild(T,e1),RightSibling(T,e1));
printf("建立树p:\n");
InitTree(p);
CreateTree(p);
printf("层序遍历树p:\n");
TraverseTree(p,vi);
printf("将树p插到树T中,请输入T中p的双亲结点 子树序号: ");
scanf("%c%d%*c",&e,&i);
InsertChild(T,e,i,p);
Print(T);
printf("删除树T中结点e的第i棵子树,请输入e i: ");
scanf("%c%d",&e,&i);
DeleteChild(T,e,i);
Print(T);
}
示例5: LogManager
void PageCoreTests::setUp()
{
// set up silent logging to not pollute output
if(LogManager::getSingletonPtr())
OGRE_DELETE Ogre::LogManager::getSingletonPtr();
if(LogManager::getSingletonPtr() == 0)
{
LogManager* logManager = OGRE_NEW LogManager();
logManager->createLog("testPageCore.log", true, false);
}
LogManager::getSingleton().setLogDetail(LL_LOW);
#if OGRE_STATIC
mStaticPluginLoader = OGRE_NEW StaticPluginLoader();
#endif
#ifdef OGRE_STATIC_LIB
mRoot = OGRE_NEW Root(StringUtil::BLANK);
mStaticPluginLoader.load();
#else
mRoot = OGRE_NEW Root();
#endif
LogManager::getSingleton().setLogDetail(LL_LOW);
mPageManager = OGRE_NEW PageManager();
// make certain the resource location is NOT read-only
ResourceGroupManager::getSingleton().addResourceLocation("./", "FileSystem",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, false, false);
mSceneMgr = mRoot->createSceneManager(ST_GENERIC);
}
示例6: if
void
BluetoothDevice::SetPropertyByValue(const BluetoothNamedValue& aValue)
{
const nsString& name = aValue.name();
const BluetoothValue& value = aValue.value();
if (name.EqualsLiteral("Name")) {
mName = value.get_nsString();
} else if (name.EqualsLiteral("Path")) {
MOZ_ASSERT(value.get_nsString().Length() > 0);
mPath = value.get_nsString();
} else if (name.EqualsLiteral("Address")) {
mAddress = value.get_nsString();
} else if (name.EqualsLiteral("Class")) {
mClass = value.get_uint32_t();
} else if (name.EqualsLiteral("Icon")) {
mIcon = value.get_nsString();
} else if (name.EqualsLiteral("Connected")) {
mConnected = value.get_bool();
} else if (name.EqualsLiteral("Paired")) {
mPaired = value.get_bool();
} else if (name.EqualsLiteral("UUIDs")) {
mUuids = value.get_ArrayOfnsString();
AutoJSAPI jsapi;
if (!jsapi.Init(GetOwner())) {
BT_WARNING("Failed to initialise AutoJSAPI!");
return;
}
JSContext* cx = jsapi.cx();
JS::Rooted<JSObject*> uuids(cx);
if (NS_FAILED(nsTArrayToJSArray(cx, mUuids, &uuids))) {
BT_WARNING("Cannot set JS UUIDs object!");
return;
}
mJsUuids = uuids;
Root();
} else if (name.EqualsLiteral("Services")) {
mServices = value.get_ArrayOfnsString();
AutoJSAPI jsapi;
if (!jsapi.Init(GetOwner())) {
BT_WARNING("Failed to initialise AutoJSAPI!");
return;
}
JSContext* cx = jsapi.cx();
JS::Rooted<JSObject*> services(cx);
if (NS_FAILED(nsTArrayToJSArray(cx, mServices, &services))) {
BT_WARNING("Cannot set JS Services object!");
return;
}
mJsServices = services;
Root();
} else {
nsCString warningMsg;
warningMsg.AssignLiteral("Not handling device property: ");
warningMsg.Append(NS_ConvertUTF16toUTF8(name));
BT_WARNING(warningMsg.get());
}
}
示例7: main
int main()
{
Status i;
int j;
position p;
TElemType e;
TElemType s;
InitBiTree( T );
CreateBiTree( T );
printf("After initializing the Tree, is the Tree empty? Yes:1, No:0, the depth is: %d\n", BiTreeEmpty( T ), BiTreeDepth(T));
i = Root( T, &e );
if( i )
printf("The root of the tree is: %d\n", e);
else
printf("The tree is empty!\n");
printf("Traverse_1:\n");
LevelOrderTraverse( T, visit );
printf("Traverse_2:\n");
InOrderTraverse( T, visit );
printf("Traverse_3:\n");
PostOrderTraverse( T, visit );
printf("input the level number to be modified \n");
scanf(" %d%d", &p.level, &p.order);
e = Value( T, p);
printf("The old value is %d, input new value: ", e);
scanf(" %d", &e);
Assign( T, p, e);
printf("Traverse_1:\n");
PreOrderTraverse( T, visit );
printf("The parent of node %d is %d, left and right children are: ", e, Parent(T, e));
printf("%d, %d, left and rignt brothers are:", LeftChild(T, e), RightChild(T, e));
printf("%d, %d\n", LeftSibling(T, e), RightSibling(T, e));
InitBiTree( s );
printf("Initializing a Tree that has empty right subtree:\n");
CreateBiTree( s );
printf("The tree s insert to the tree T, input the parent node of s, s is left subtree or right subtree.");
scanf(" %d%d%d", &p.level, &p.order, &j);
DeleteChild( T, p, j);
Print( T );
clearBiTRee( T );
printf("After clearing the tree, is the tree empty? Yes:1, No:0 %d\n", BiTreeEmpty( T ), BiTreeDepth(T));
i = Root( T, &e );
if( i )
printf("The root of the bitree is %d\n", e);
else
printf("The tree is empty, no root!\n");
}
示例8: if
void
BluetoothDevice::SetPropertyByValue(const BluetoothNamedValue& aValue)
{
const nsString& name = aValue.name();
const BluetoothValue& value = aValue.value();
if (name.EqualsLiteral("Name")) {
mName = value.get_nsString();
} else if (name.EqualsLiteral("Path")) {
MOZ_ASSERT(value.get_nsString().Length() > 0);
mPath = value.get_nsString();
} else if (name.EqualsLiteral("Address")) {
mAddress = value.get_nsString();
} else if (name.EqualsLiteral("Class")) {
mClass = value.get_uint32_t();
} else if (name.EqualsLiteral("Icon")) {
mIcon = value.get_nsString();
} else if (name.EqualsLiteral("Connected")) {
mConnected = value.get_bool();
} else if (name.EqualsLiteral("Paired")) {
mPaired = value.get_bool();
} else if (name.EqualsLiteral("UUIDs")) {
mUuids = value.get_ArrayOfnsString();
nsresult rv;
nsIScriptContext* sc = GetContextForEventHandlers(&rv);
if (sc) {
rv =
nsTArrayToJSArray(sc->GetNativeContext(), mUuids, &mJsUuids);
if (NS_FAILED(rv)) {
NS_WARNING("Cannot set JS UUIDs object!");
return;
}
Root();
} else {
NS_WARNING("Could not get context!");
}
} else if (name.EqualsLiteral("Services")) {
mServices = value.get_ArrayOfnsString();
nsresult rv;
nsIScriptContext* sc = GetContextForEventHandlers(&rv);
if (sc) {
rv =
nsTArrayToJSArray(sc->GetNativeContext(), mServices, &mJsServices);
if (NS_FAILED(rv)) {
NS_WARNING("Cannot set JS Services object!");
return;
}
Root();
} else {
NS_WARNING("Could not get context!");
}
#ifdef DEBUG
} else {
nsCString warningMsg;
warningMsg.AssignLiteral("Not handling device property: ");
warningMsg.Append(NS_ConvertUTF16toUTF8(name));
NS_WARNING(warningMsg.get());
#endif
}
}
示例9: if
void
BluetoothDevice::SetPropertyByValue(const BluetoothNamedValue& aValue)
{
const nsString& name = aValue.name();
const BluetoothValue& value = aValue.value();
if (name.EqualsLiteral("Name")) {
mName = value.get_nsString();
} else if (name.EqualsLiteral("Path")) {
MOZ_ASSERT(value.get_nsString().Length() > 0);
mPath = value.get_nsString();
} else if (name.EqualsLiteral("Address")) {
mAddress = value.get_nsString();
} else if (name.EqualsLiteral("Class")) {
mClass = value.get_uint32_t();
} else if (name.EqualsLiteral("Icon")) {
mIcon = value.get_nsString();
} else if (name.EqualsLiteral("Connected")) {
mConnected = value.get_bool();
} else if (name.EqualsLiteral("Paired")) {
mPaired = value.get_bool();
} else if (name.EqualsLiteral("UUIDs")) {
mUuids = value.get_ArrayOfnsString();
nsresult rv;
nsIScriptContext* sc = GetContextForEventHandlers(&rv);
NS_ENSURE_SUCCESS_VOID(rv);
NS_ENSURE_TRUE_VOID(sc);
AutoPushJSContext cx(sc->GetNativeContext());
JS::Rooted<JSObject*> uuids(cx);
if (NS_FAILED(nsTArrayToJSArray(cx, mUuids, uuids.address()))) {
BT_WARNING("Cannot set JS UUIDs object!");
return;
}
mJsUuids = uuids;
Root();
} else if (name.EqualsLiteral("Services")) {
mServices = value.get_ArrayOfnsString();
nsresult rv;
nsIScriptContext* sc = GetContextForEventHandlers(&rv);
NS_ENSURE_SUCCESS_VOID(rv);
NS_ENSURE_TRUE_VOID(sc);
AutoPushJSContext cx(sc->GetNativeContext());
JS::Rooted<JSObject*> services(cx);
if (NS_FAILED(nsTArrayToJSArray(cx, mServices, services.address()))) {
BT_WARNING("Cannot set JS Services object!");
return;
}
mJsServices = services;
Root();
} else {
nsCString warningMsg;
warningMsg.AssignLiteral("Not handling device property: ");
warningMsg.Append(NS_ConvertUTF16toUTF8(name));
BT_WARNING(warningMsg.get());
}
}
示例10: OGRE_NEW_T
//--------------------------------------------------------------------------
void MeshLodTests::setUp()
{
mFSLayer = OGRE_NEW_T(Ogre::FileSystemLayer, Ogre::MEMCATEGORY_GENERAL)(OGRE_VERSION_NAME);
#ifdef OGRE_STATIC_LIB
mStaticPluginLoader = OGRE_NEW StaticPluginLoader();
Root* root = OGRE_NEW Root(BLANKSTRING);
mStaticPluginLoader.load();
#else
String pluginsPath = mFSLayer->getConfigFilePath("plugins.cfg");
Root* root = OGRE_NEW Root(pluginsPath);
#endif
CPPUNIT_ASSERT(!root->getAvailableRenderers().empty());
root->setRenderSystem(root->getAvailableRenderers().back());
root->initialise(false); // Needed for setting up HardwareBufferManager
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
Ogre::NameValuePairList misc;
// Tell OGRE that we're using cocoa, so it doesn't need to make a window for us
misc["macAPI"] = "cocoa";
root->createRenderWindow("", 320, 240, false, &misc)->setHidden(true);
#else
root->createRenderWindow("", 320, 240, false, NULL)->setHidden(true);
#endif
new MeshLodGenerator;
// Load resource paths from config file
ConfigFile cf;
String resourcesPath;
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE || OGRE_PLATFORM == OGRE_PLATFORM_WIN32
resourcesPath = mFSLayer->getConfigFilePath("resources.cfg");
#else
resourcesPath = mFSLayer->getConfigFilePath("bin/resources.cfg");
#endif
cf.load(resourcesPath);
// Go through all sections & settings in the file
ConfigFile::SectionIterator seci = cf.getSectionIterator();
String secName, typeName, archName;
while (seci.hasMoreElements()) {
secName = seci.peekNextKey();
ConfigFile::SettingsMultiMap* settings = seci.getNext();
ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i) {
typeName = i->first;
archName = i->second;
ResourceGroupManager::getSingleton().addResourceLocation(
archName, typeName, secName);
}
}
// Create the mesh for testing
mMesh = MeshManager::getSingleton().load("Sinbad.mesh", ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
}
示例11: LogManager
void TerrainTests::setUp()
{
// set up silent logging to not pollute output
if(LogManager::getSingletonPtr())
OGRE_DELETE Ogre::LogManager::getSingletonPtr();
if(LogManager::getSingletonPtr() == 0)
{
LogManager* logManager = OGRE_NEW LogManager();
logManager->createLog("testTerrain.log", true, false);
}
LogManager::getSingleton().setLogDetail(LL_LOW);
mFSLayer = OGRE_NEW_T(Ogre::FileSystemLayer, Ogre::MEMCATEGORY_GENERAL)(OGRE_VERSION_NAME);
#ifdef OGRE_STATIC_LIB
mRoot = OGRE_NEW Root(BLANKSTRING);
mStaticPluginLoader.load();
#else
String pluginsPath = mFSLayer->getConfigFilePath("plugins.cfg");
mRoot = OGRE_NEW Root(pluginsPath);
#endif
mTerrainOpts = OGRE_NEW TerrainGlobalOptions();
// Load resource paths from config file
ConfigFile cf;
String resourcesPath;
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE || OGRE_PLATFORM == OGRE_PLATFORM_WIN32
resourcesPath = mFSLayer->getConfigFilePath("resources.cfg");
#else
resourcesPath = mFSLayer->getConfigFilePath("bin/resources.cfg");
#endif
cf.load(resourcesPath);
// Go through all sections & settings in the file
ConfigFile::SectionIterator seci = cf.getSectionIterator();
String secName, typeName, archName;
while (seci.hasMoreElements())
{
secName = seci.peekNextKey();
ConfigFile::SettingsMultiMap *settings = seci.getNext();
ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
archName = i->second;
ResourceGroupManager::getSingleton().addResourceLocation(
archName, typeName, secName);
}
}
mSceneMgr = mRoot->createSceneManager(ST_GENERIC);
}
示例12: Root
int Set::Find(int a, int b)
{
if(type == _QUICKFIND)
{
return array[a] == array[b];
}
if(type == _QUICKUNION || type == _QUICKUNION_WEIGHTED)
{
return Root(a) == Root(b);
}
}
示例13: my_powr
static base_t my_powr(const base_t&i, int p, unsigned q)
{
base_t po(Power(i, p));
if((q & 0x1) && my_inf(po) < 0) {
if(my_sup(po) <= 0)
return -Root(Abs(po), q);
base_t r(Root(Abs(po), q));
r = base_t(-Sup(r), Sup(r));
return r;
}
return Root(po,q);
}
示例14: Union
void Union(int id_obj1, int id_obj2) {
int root_id_obj1 = Root(id_obj1);
int root_id_obj2 = Root(id_obj2);
// We use the number of elements to weight the tree.
if (union_vector_[root_id_obj1].size_of_union > union_vector_[root_id_obj2].size_of_union) {
union_vector_[root_id_obj2].root_id = union_vector_[root_id_obj1].root_id;
union_vector_[root_id_obj1].size_of_union += union_vector_[root_id_obj2].size_of_union;
} else {
union_vector_[root_id_obj1].root_id = union_vector_[root_id_obj2].root_id;
union_vector_[root_id_obj2].size_of_union += union_vector_[root_id_obj1].size_of_union;
}
}
示例15: main
void main()
{
Status i;
int j;
position p;
TElemType e;
SqBiTree T,s;
InitBiTree(T);
CreateBiTree(T);
printf("建立二叉树后,树空否?%d(1:是 0:否) 树的深度=%d\n",BiTreeEmpty(T),BiTreeDepth(T));
i=Root(T,&e);
if(i)
printf("二叉树的根为:%d\n",e);
else
printf("树空,无根\n");
printf("层序遍历二叉树:\n");
LevelOrderTraverse(T,visit);
printf("中序遍历二叉树:\n");
InOrderTraverse(T,visit);
printf("后序遍历二叉树:\n");
PostOrderTraverse(T,visit);
printf("请输入待修改结点的层号 本层序号: ");
scanf("%d%d",&p.level,&p.order);
e=Value(T,p);
printf("待修改结点的原值为%d请输入新值: ",e);
scanf("%d",&e);
Assign(T,p,e);
printf("先序遍历二叉树:\n");
PreOrderTraverse(T,visit);
printf("结点%d的双亲为%d,左右孩子分别为",e,Parent(T,e));
printf("%d,%d,左右兄弟分别为",LeftChild(T,e),RightChild(T,e));
printf("%d,%d\n",LeftSibling(T,e),RightSibling(T,e));
InitBiTree(s);
printf("建立右子树为空的树s:\n");
CreateBiTree(s);
printf("树s插到树T中,请输入树T中树s的双亲结点 s为左(0)或右(1)子树: ");
scanf("%d%d",&e,&j);
InsertChild(T,e,j,s);
Print(T);
printf("删除子树,请输入待删除子树根结点的层号 本层序号 左(0)或右(1)子树: ");
scanf("%d%d%d",&p.level,&p.order,&j);
DeleteChild(T,p,j);
Print(T);
ClearBiTree(T);
printf("清除二叉树后,树空否?%d(1:是 0:否) 树的深度=%d\n",BiTreeEmpty(T),BiTreeDepth(T));
i=Root(T,&e);
if(i)
printf("二叉树的根为:%d\n",e);
else
printf("树空,无根\n");
}