本文整理汇总了C++中JArray::InsertSorted方法的典型用法代码示例。如果您正苦于以下问题:C++ JArray::InsertSorted方法的具体用法?C++ JArray::InsertSorted怎么用?C++ JArray::InsertSorted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JArray
的用法示例。
在下文中一共展示了JArray::InsertSorted方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getpwuid
static JBoolean
jGetUserInfo
(
const uid_t uid,
jUIDInfo* info
)
{
if (theUserInfoMap.IsEmpty())
{
theUserInfoMap.SetCompareFunction(jCompareUIDs);
theUserInfoMap.SetSortOrder(JOrderedSetT::kSortAscending);
atexit(jCleanUserInfoMap);
}
const jUIDInfo target = { uid, NULL, NULL };
JIndex i;
if (theUserInfoMap.SearchSorted(target, JOrderedSetT::kAnyMatch, &i))
{
*info = theUserInfoMap.GetElement(i);
}
else
{
passwd* pwbuf = getpwuid(uid);
if (pwbuf != NULL)
{
info->userName = new JString(pwbuf->pw_name);
assert( info->userName != NULL );
info->realName = new JString(pwbuf->pw_gecos);
assert( info->realName != NULL );
info->homeDirectory = new JString(pwbuf->pw_dir);
assert( info->homeDirectory != NULL );
info->shell = new JString(pwbuf->pw_shell);
assert( info->shell != NULL );
info->id = uid;
const JBoolean inserted = theUserInfoMap.InsertSorted(*info, kJFalse);
assert( inserted );
}
else
{
info->userName = info->realName = info->homeDirectory = info->shell = NULL;
}
}
return JI2B( info->userName != NULL );
}
示例2: getgrgid
static JBoolean
jGetGroupInfo
(
const gid_t gid,
jGIDInfo* info
)
{
if (groupInfoMap.IsEmpty())
{
groupInfoMap.SetCompareFunction(jCompareGIDs);
groupInfoMap.SetSortOrder(JOrderedSetT::kSortAscending);
}
const jGIDInfo target = { gid, NULL };
JIndex i;
if (groupInfoMap.SearchSorted(target, JOrderedSetT::kAnyMatch, &i))
{
*info = groupInfoMap.GetElement(i);
}
else
{
group* grpbuf = getgrgid(gid);
if (grpbuf != NULL)
{
info->groupName = new JString(grpbuf->gr_name);
assert( info->groupName != NULL );
info->id = gid;
const JBoolean inserted = groupInfoMap.InsertSorted(*info, kJFalse);
assert( inserted );
}
else
{
info->groupName = NULL;
}
}
return JI2B( info->groupName != NULL );
}