本文整理汇总了C++中nsDataHashtable::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ nsDataHashtable::Clear方法的具体用法?C++ nsDataHashtable::Clear怎么用?C++ nsDataHashtable::Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsDataHashtable
的用法示例。
在下文中一共展示了nsDataHashtable::Clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: void
void
BluetoothServiceBluedroid::AdapterStateChangedNotification(bool aState)
{
MOZ_ASSERT(NS_IsMainThread());
BT_LOGR("BT_STATE: %d", aState);
sAdapterEnabled = aState;
if (!sAdapterEnabled) {
static void (* const sDeinitManager[])(BluetoothProfileResultHandler*) = {
BluetoothHfpManager::DeinitHfpInterface,
BluetoothA2dpManager::DeinitA2dpInterface,
BluetoothGattManager::DeinitGattInterface
};
// Return error if BluetoothService is unavailable
BluetoothService* bs = BluetoothService::Get();
NS_ENSURE_TRUE_VOID(bs);
// Cleanup static adapter properties and notify adapter.
sAdapterBdAddress.Truncate();
sAdapterBdName.Truncate();
InfallibleTArray<BluetoothNamedValue> props;
BT_APPEND_NAMED_VALUE(props, "Name", sAdapterBdName);
BT_APPEND_NAMED_VALUE(props, "Address", sAdapterBdAddress);
if (sAdapterDiscoverable) {
sAdapterDiscoverable = false;
BT_APPEND_NAMED_VALUE(props, "Discoverable", false);
}
if (sAdapterDiscovering) {
sAdapterDiscovering = false;
BT_APPEND_NAMED_VALUE(props, "Discovering", false);
}
bs->DistributeSignal(NS_LITERAL_STRING("PropertyChanged"),
NS_LITERAL_STRING(KEY_ADAPTER),
BluetoothValue(props));
// Cleanup bluetooth interfaces after BT state becomes BT_STATE_OFF.
nsRefPtr<ProfileDeinitResultHandler> res =
new ProfileDeinitResultHandler(MOZ_ARRAY_LENGTH(sDeinitManager));
for (size_t i = 0; i < MOZ_ARRAY_LENGTH(sDeinitManager); ++i) {
sDeinitManager[i](res);
}
}
BluetoothService::AcknowledgeToggleBt(sAdapterEnabled);
if (sAdapterEnabled) {
// Bluetooth just enabled, clear profile controllers and runnable arrays.
sControllerArray.Clear();
sChangeDiscoveryRunnableArray.Clear();
sSetPropertyRunnableArray.Clear();
sGetDeviceRunnableArray.Clear();
sFetchUuidsRunnableArray.Clear();
sBondingRunnableArray.Clear();
sUnbondingRunnableArray.Clear();
sPairingNameTable.Clear();
// Bluetooth scan mode is SCAN_MODE_CONNECTABLE by default, i.e., it should
// be connectable and non-discoverable.
NS_ENSURE_TRUE_VOID(sBtInterface);
sBtInterface->SetAdapterProperty(
BluetoothNamedValue(NS_ConvertUTF8toUTF16("Discoverable"), false),
new SetAdapterPropertyDiscoverableResultHandler());
// Trigger BluetoothOppManager to listen
BluetoothOppManager* opp = BluetoothOppManager::Get();
if (!opp || !opp->Listen()) {
BT_LOGR("Fail to start BluetoothOppManager listening");
}
}
// Resolve promise if existed
if (!sChangeAdapterStateRunnableArray.IsEmpty()) {
DispatchReplySuccess(sChangeAdapterStateRunnableArray[0]);
sChangeAdapterStateRunnableArray.RemoveElementAt(0);
}
}
示例2: key
//.........这里部分代码省略.........
// if actualOverlap == 0.5
// 1 2 3
// +-------+-------+-------+---+
// | ##### | ***** | ##### |## |
// |#######|*******|##### C_n #|
// |###+###|***+***|###+###+###|
// |# C_0 #|* C_1 *|# C_2 #|###|
// | ##### | ***** | ##### |## |
// +-------+-------+-------+---+
// |
// V
// +-------+-+-------+-+-------+
// | ##### | | ##### | | ##### |
// |#######| |#######| |#######|
// |###+###| |###+###| |###+###| Even if we place C_1 at the middle
// |# C_0 #| |# C_1 #| |# C_n #| of them, it's too near from them
// | ##### | | ##### | | ##### |
// +-------+-+-------+-|-------+
// |
// V
// +-------+-----------+-------+
// | ##### | | ##### |
// |#######| |#######|
// |###+###| |###+###| Do not draw any circle
// |# C_0 #| |# C_n #|
// | ##### | | ##### |
// +-------+-----------+-------+
mCount = 0;
break;
}
// targetCount should be 2n, as we're searching C_1 to C_n.
//
// targetCount = 4
// mCount = 1
// 1 2 3 4
// +-------+-------+-------+-------+-------+
// | ##### | ***** | ##### | ***** | ##### |
// |#######|*******|#######|*******|#######|
// |###+###|***+***|###+###|***+***|###+###|
// |# C_0 #|* C_1 *|# C_2 #|* C_3 *|# C_n #|
// | ##### | ***** | ##### | ***** | ##### |
// +-------+-------+-------+-------+-------+
// 1
//
// targetCount = 6
// mCount = 2
// 1 2 3 4 5 6
// +-------+-------+-------+-------+-------+-------+-------+
// | ##### | ***** | ##### | ***** | ##### | ***** | ##### |
// |#######|*******|#######|*******|#######|*******|#######|
// |###+###|***+***|###+###|***+***|###+###|***+***|###+###|
// |# C_0 #|* C_1 *|# C_2 #|* C_3 *|# C_4 #|* C_5 *|# C_n #|
// | ##### | ***** | ##### | ***** | ##### | ***** | ##### |
// +-------+-------+-------+-------+-------+-------+-------+
// 1 2
if (count % 2) {
targetCount = count + 1;
} else {
targetCount = count;
}
mCount = targetCount / 2 - 1;
}
if (count == targetCount) {
mBestOverlap = overlap;
if (fabs(actualOverlap - overlap) < OVERLAP_MARGIN) {
break;
}
// We started from upper bound, no need to update range when j == 0.
if (j > 0) {
if (actualOverlap > overlap) {
lower = overlap;
} else {
upper = overlap;
}
}
} else {
// |j == 0 && count != targetCount| means that |targetCount = count + 1|,
// and we started from upper bound, no need to update range when j == 0.
if (j > 0) {
if (count > targetCount) {
upper = overlap;
} else {
lower = overlap;
}
}
}
overlap = (upper + lower) / 2.0f;
}
if (DottedCornerCache.Count() > DottedCornerCacheSize) {
DottedCornerCache.Clear();
}
DottedCornerCache.Put(key, BestOverlap(mBestOverlap, mCount));
}