本文整理汇总了C++中BList::IsEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ BList::IsEmpty方法的具体用法?C++ BList::IsEmpty怎么用?C++ BList::IsEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BList
的用法示例。
在下文中一共展示了BList::IsEmpty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestBlockCache
void BlockCacheConcurrencyTest::TestBlockCache(BBlockCache *theCache,
bool isMallocTest)
{
BList cacheList;
BList nonCacheList;
thread_id theThread = find_thread(NULL);
// Do everything eight times to ensure the test runs long
// enough to check for concurrency problems.
for (int j = 0; j < 8; j++) {
// Perform a series of gets, saves and frees
for (int i = 0; i < numBlocksInCache / 2; i++) {
GetBlock(theCache, sizeOfBlocksInCache, theThread, &cacheList, &nonCacheList);
GetBlock(theCache, sizeOfBlocksInCache, theThread, &cacheList, &nonCacheList);
GetBlock(theCache, sizeOfNonCacheBlocks, theThread, &cacheList, &nonCacheList);
GetBlock(theCache, sizeOfNonCacheBlocks, theThread, &cacheList, &nonCacheList);
SaveBlock(theCache, cacheList.ItemAt(cacheList.CountItems() / 2),
sizeOfBlocksInCache, theThread, &cacheList, &nonCacheList);
SaveBlock(theCache, nonCacheList.ItemAt(nonCacheList.CountItems() / 2),
sizeOfNonCacheBlocks, theThread, &cacheList, &nonCacheList);
GetBlock(theCache, sizeOfBlocksInCache, theThread, &cacheList, &nonCacheList);
GetBlock(theCache, sizeOfBlocksInCache, theThread, &cacheList, &nonCacheList);
GetBlock(theCache, sizeOfNonCacheBlocks, theThread, &cacheList, &nonCacheList);
GetBlock(theCache, sizeOfNonCacheBlocks, theThread, &cacheList, &nonCacheList);
FreeBlock(cacheList.ItemAt(cacheList.CountItems() / 2),
sizeOfBlocksInCache, isMallocTest, theThread, &cacheList, &nonCacheList);
FreeBlock(nonCacheList.ItemAt(nonCacheList.CountItems() / 2),
sizeOfNonCacheBlocks, isMallocTest, theThread, &cacheList, &nonCacheList);
}
bool performFree = false;
// Free or save (every other block) for all "cache sized" blocks.
while (!cacheList.IsEmpty()) {
if (performFree) {
FreeBlock(cacheList.LastItem(), sizeOfBlocksInCache, isMallocTest, theThread, &cacheList,
&nonCacheList);
} else {
SaveBlock(theCache, cacheList.LastItem(), sizeOfBlocksInCache, theThread, &cacheList,
&nonCacheList);
}
performFree = !performFree;
}
// Free or save (every other block) for all "non-cache sized" blocks.
while (!nonCacheList.IsEmpty()) {
if (performFree) {
FreeBlock(nonCacheList.LastItem(), sizeOfNonCacheBlocks, isMallocTest, theThread, &cacheList,
&nonCacheList);
} else {
SaveBlock(theCache, nonCacheList.LastItem(), sizeOfNonCacheBlocks, theThread, &cacheList,
&nonCacheList);
}
performFree = !performFree;
}
}
}
示例2: lround
// _CalculateSumWeight
long
SimpleLayouter::_CalculateSumWeight(BList& elementInfos)
{
if (elementInfos.IsEmpty())
return 0;
int32 count = elementInfos.CountItems();
// sum up the floating point weight, so we get a scale
double scale = 0;
for (int32 i = 0; i < count; i++) {
ElementInfo* info = (ElementInfo*)elementInfos.ItemAt(i);
scale += info->weight;
}
int64 weight = 0;
if (scale == 0) {
// The weight sum is 0: We assign each info a temporary weight of 1.
for (int32 i = 0; i < count; i++) {
ElementInfo* info = (ElementInfo*)elementInfos.ItemAt(i);
info->tempWeight = 1;
weight += info->tempWeight;
}
} else {
// We scale the weights so that their sum is about 100000. This should
// give us ample resolution. If possible make the scale integer, so that
// integer weights will produce exact results.
if (scale >= 1 && scale <= 100000)
scale = lround(100000 / scale);
else
scale = 100000 / scale;
for (int32 i = 0; i < count; i++) {
ElementInfo* info = (ElementInfo*)elementInfos.ItemAt(i);
info->tempWeight = (int64)(info->weight * scale);
weight += info->tempWeight;
}
}
return weight;
}
示例3: TRACE
// _LoadAddOns
status_t
DiskSystemAddOnManager::_LoadAddOns(StringSet& alreadyLoaded,
directory_which addOnDir)
{
// get the add-on directory path
BPath path;
status_t error = find_directory(addOnDir, &path, false);
if (error != B_OK)
return error;
TRACE("DiskSystemAddOnManager::_LoadAddOns(): %s\n", path.Path());
error = path.Append("disk_systems");
if (error != B_OK)
return error;
if (!BEntry(path.Path()).Exists())
return B_OK;
// open the directory and iterate through its entries
BDirectory directory;
error = directory.SetTo(path.Path());
if (error != B_OK)
return error;
entry_ref ref;
while (directory.GetNextRef(&ref) == B_OK) {
// skip, if already loaded
if (alreadyLoaded.find(ref.name) != alreadyLoaded.end()) {
TRACE(" skipping \"%s\" -- already loaded\n", ref.name);
continue;
}
// get the entry path
BPath entryPath;
error = entryPath.SetTo(&ref);
if (error != B_OK) {
if (error == B_NO_MEMORY)
return error;
TRACE(" skipping \"%s\" -- failed to get path\n", ref.name);
continue;
}
// load the add-on
image_id image = load_add_on(entryPath.Path());
if (image < 0) {
TRACE(" skipping \"%s\" -- failed to load add-on\n", ref.name);
continue;
}
AddOnImage* addOnImage = new(nothrow) AddOnImage(image);
if (!addOnImage) {
unload_add_on(image);
return B_NO_MEMORY;
}
ObjectDeleter<AddOnImage> addOnImageDeleter(addOnImage);
// get the add-on objects
status_t (*getAddOns)(BList*);
error = get_image_symbol(image, "get_disk_system_add_ons",
B_SYMBOL_TYPE_TEXT, (void**)&getAddOns);
if (error != B_OK) {
TRACE(" skipping \"%s\" -- function symbol not found\n", ref.name);
continue;
}
BList addOns;
error = getAddOns(&addOns);
if (error != B_OK || addOns.IsEmpty()) {
TRACE(" skipping \"%s\" -- getting add-ons failed\n", ref.name);
continue;
}
// create and add AddOn objects
int32 count = addOns.CountItems();
for (int32 i = 0; i < count; i++) {
BDiskSystemAddOn* diskSystemAddOn
= (BDiskSystemAddOn*)addOns.ItemAt(i);
AddOn* addOn = new(nothrow) AddOn(addOnImage, diskSystemAddOn);
if (!addOn)
return B_NO_MEMORY;
if (fAddOns.AddItem(addOn)) {
addOnImage->refCount++;
addOnImageDeleter.Detach();
} else {
delete addOn;
return B_NO_MEMORY;
}
}
TRACE(" got %ld BDiskSystemAddOn(s) from add-on \"%s\"\n", count,
ref.name);
// add the add-on name to the set of already loaded add-ons
try {
alreadyLoaded.insert(ref.name);
} catch (std::bad_alloc& exception) {
return B_NO_MEMORY;
//.........这里部分代码省略.........
示例4: entry
int
main(int argc, char** argv)
{
int exitCode = EXIT_SUCCESS;
const char* openWith = NULL;
char* progName = argv[0];
if (strrchr(progName, '/'))
progName = strrchr(progName, '/') + 1;
if (argc < 2) {
fprintf(stderr,"usage: %s <file[:line[:column]] or url or application "
"signature> ...\n", progName);
}
while (*++argv) {
status_t result = B_OK;
argc--;
BEntry entry(*argv);
if ((result = entry.InitCheck()) == B_OK && entry.Exists()) {
result = open_file(openWith, entry);
} else if (!strncasecmp("application/", *argv, 12)) {
// maybe it's an application-mimetype?
// subsequent files are open with that app
openWith = *argv;
// in the case the app is already started,
// don't start it twice if we have other args
BList teams;
if (argc > 1)
be_roster->GetAppList(*argv, &teams);
if (teams.IsEmpty())
result = be_roster->Launch(*argv);
else
result = B_OK;
} else if (strchr(*argv, ':')) {
// try to open it as an URI
BUrl url(*argv);
if (url.OpenWithPreferredApplication() == B_OK) {
result = B_OK;
continue;
}
// maybe it's "file:line" or "file:line:col"
int line = 0, col = 0, i;
result = B_ENTRY_NOT_FOUND;
// remove gcc error's last :
BString arg(*argv);
if (arg[arg.Length() - 1] == ':')
arg.Truncate(arg.Length() - 1);
i = arg.FindLast(':');
if (i > 0) {
line = atoi(arg.String() + i + 1);
arg.Truncate(i);
result = entry.SetTo(arg.String());
if (result == B_OK && entry.Exists()) {
result = open_file(openWith, entry, line);
if (result == B_OK)
continue;
}
// get the column
col = line;
i = arg.FindLast(':');
line = atoi(arg.String() + i + 1);
arg.Truncate(i);
result = entry.SetTo(arg.String());
if (result == B_OK && entry.Exists())
result = open_file(openWith, entry, line, col);
}
} else
result = B_ENTRY_NOT_FOUND;
if (result != B_OK && result != B_ALREADY_RUNNING) {
fprintf(stderr, "%s: \"%s\": %s\n", progName, *argv,
strerror(result));
// make sure the shell knows this
exitCode = EXIT_FAILURE;
}
}
return exitCode;
}
示例5: BString
void
TBarView::ChangeState(int32 state, bool vertical, bool left, bool top)
{
bool vertSwap = (fVertical != vertical);
bool leftSwap = (fLeft != left);
fState = state;
fVertical = vertical;
fLeft = left;
fTop = top;
BRect screenFrame = (BScreen(Window())).Frame();
PlaceBeMenu();
if (fVertical){
#if SA_CLOCK
PlaceClock(); // tray dependent on clock location
#endif
PlaceTray(vertSwap, leftSwap, screenFrame);
} else {
PlaceTray(vertSwap, leftSwap, screenFrame);
#if SA_CLOCK
PlaceClock(); // clock is dependent on tray location
#endif
}
// We need to keep track of what apps are expanded.
BList expandedItems;
BString *signature = NULL;
if (fVertical && Expando() && static_cast<TBarApp *>(be_app)->Settings()->superExpando) {
// Get a list of the Signatures of expanded apps - Can't use team_id because
// there can be more than one team per application
if (fVertical && Expando() && vertical && fExpando) {
for (int index = 0; index < fExpando->CountItems(); index++) {
TTeamMenuItem *item = dynamic_cast<TTeamMenuItem *>(fExpando->ItemAt(index));
if (item != NULL && item->IsExpanded()) {
signature = new BString(item->Signature());
expandedItems.AddItem((void *)signature);
}
}
}
}
PlaceApplicationBar(screenFrame);
SizeWindow(screenFrame);
PositionWindow(screenFrame);
Window()->UpdateIfNeeded();
// Re-expand those apps.
if (expandedItems.CountItems() > 0) {
for (int sigIndex = expandedItems.CountItems(); sigIndex-- > 0;) {
signature = static_cast<BString *>(expandedItems.ItemAt(sigIndex));
if (signature == NULL)
continue;
// Start at the 'bottom' of the list working up.
// Prevents being thrown off by expanding items.
for (int teamIndex = fExpando->CountItems(); teamIndex-- > 0;) {
TTeamMenuItem *item = dynamic_cast<TTeamMenuItem *>(fExpando->ItemAt(teamIndex));
if (item != NULL && !signature->Compare(item->Signature())) {
item->ToggleExpandState(false);
break;
}
}
}
// Clean up expanded signature list.
while (!expandedItems.IsEmpty()) {
delete static_cast<BString *>(expandedItems.RemoveItem((int32)0));
}
fExpando->SizeWindow();
}
Invalidate();
}