blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
201
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
7
100
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
260 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
11.4k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
80 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
8
9.86M
extension
stringclasses
52 values
content
stringlengths
8
9.86M
authors
listlengths
1
1
author
stringlengths
0
119
43e87733b8647bce65bc5da5637b6c6b57038418
8bc3a5b243ce9db4c2aa7e05d0df503e81fff2f4
/F746_controller/Src/Flash.cpp
ef536eca8d407b99e836dbfda7cd234c1057fe0e
[]
no_license
yasuohayashibara/STM_BLDC_Controller_Ixion
13f8a3ab9dbe002081f7f39395fcbb4e4cbd9e56
25c789c2c4d5b689b54fd855debca02c9988fb56
refs/heads/master
2020-03-13T14:01:33.438992
2018-06-21T04:33:56
2018-06-21T04:33:56
131,150,255
1
1
null
null
null
null
UTF-8
C++
false
false
2,327
cpp
#include "Flash.h" typedef struct { uint32_t base_address; uint32_t sector_size; uint32_t sector_count; } flash_layout_t; #define FLASH_FLAG_PGSERR FLASH_FLAG_ERSERR static const flash_layout_t flash_layout[] = { { 0x08000000, 0x08000, 4 }, { 0x08020000, 0x20000, 1 }, { 0x08040000, 0x40000, 3 }, }; uint32_t flash_get_sector_info(uint32_t addr, uint32_t *start_addr, uint32_t *size) { if (addr >= flash_layout[0].base_address) { uint32_t sector_index = 0; for (int i = 0; i < sizeof(flash_layout)/sizeof(flash_layout_t); ++i) { for (int j = 0; j < flash_layout[i].sector_count; ++j) { uint32_t sector_start_next = flash_layout[i].base_address + (j + 1) * flash_layout[i].sector_size; if (addr < sector_start_next) { if (start_addr != NULL) { *start_addr = flash_layout[i].base_address + j * flash_layout[i].sector_size; } if (size != NULL) { *size = flash_layout[i].sector_size; } return sector_index; } ++sector_index; } } } return 0; } bool Flash::write(uint32_t addr, uint8_t* dat, uint16_t size) { int i; FLASH_EraseInitTypeDef EraseInitStruct; uint32_t PageError = 0; HAL_StatusTypeDef r; r = HAL_FLASH_Unlock(); if( r != HAL_OK ){ return false; } __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR); EraseInitStruct.TypeErase = FLASH_TYPEERASE_SECTORS; EraseInitStruct.VoltageRange = VOLTAGE_RANGE_3; EraseInitStruct.Sector = flash_get_sector_info(addr, NULL, NULL); EraseInitStruct.NbSectors = flash_get_sector_info(addr + size - 1, NULL, NULL) - EraseInitStruct.Sector + 1; r = HAL_FLASHEx_Erase(&EraseInitStruct, &PageError); if ( r != HAL_OK ) { return false; } for(i = 0; i < size; i += 2){ r = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, addr+i, *(uint16_t*)(dat+i)); if( r != HAL_OK ){ HAL_FLASH_Lock(); return false; } } r = HAL_FLASH_Lock(); if( r != HAL_OK ){ return false; } return true; }
[ "yasuo.hayashibara@it-chiba.ac.jp" ]
yasuo.hayashibara@it-chiba.ac.jp
b29bc8b4aa5738170232d09844abeca81ee18b95
67f988dedfd8ae049d982d1a8213bb83233d90de
/external/chromium/chrome/browser/extensions/extension_sorting_unittest.cc
dfee25dd469238cbf78d681f583e8c873bd962fa
[ "BSD-3-Clause" ]
permissive
opensourceyouthprogramming/h5vcc
94a668a9384cc3096a365396b5e4d1d3e02aacc4
d55d074539ba4555e69e9b9a41e5deb9b9d26c5b
refs/heads/master
2020-04-20T04:57:47.419922
2019-02-12T00:56:14
2019-02-12T00:56:14
168,643,719
1
1
null
2019-02-12T00:49:49
2019-02-01T04:47:32
C++
UTF-8
C++
false
false
38,340
cc
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/extensions/extension_sorting.h" #include <map> #include "chrome/browser/extensions/extension_prefs_unittest.h" #include "chrome/common/extensions/extension_manifest_constants.h" #include "sync/api/string_ordinal.h" #include "testing/gtest/include/gtest/gtest.h" using extensions::Extension; namespace keys = extension_manifest_keys; class ExtensionSortingTest : public extensions::ExtensionPrefsTest { protected: ExtensionSorting* extension_sorting() { return prefs()->extension_sorting(); } }; class ExtensionSortingAppLocation : public ExtensionSortingTest { public: virtual void Initialize() OVERRIDE { extension_ = prefs_.AddExtension("not_an_app"); // Non-apps should not have any app launch ordinal or page ordinal. prefs()->OnExtensionInstalled(extension_.get(), Extension::ENABLED, syncer::StringOrdinal()); } virtual void Verify() OVERRIDE { EXPECT_FALSE( extension_sorting()->GetAppLaunchOrdinal(extension_->id()).IsValid()); EXPECT_FALSE( extension_sorting()->GetPageOrdinal(extension_->id()).IsValid()); } private: scoped_refptr<Extension> extension_; }; TEST_F(ExtensionSortingAppLocation, ExtensionSortingAppLocation) {} class ExtensionSortingAppLaunchOrdinal : public ExtensionSortingTest { public: virtual void Initialize() OVERRIDE { // No extensions yet. syncer::StringOrdinal page = syncer::StringOrdinal::CreateInitialOrdinal(); EXPECT_TRUE(syncer::StringOrdinal::CreateInitialOrdinal().Equals( extension_sorting()->CreateNextAppLaunchOrdinal(page))); extension_ = prefs_.AddApp("on_extension_installed"); EXPECT_FALSE(prefs()->IsExtensionDisabled(extension_->id())); prefs()->OnExtensionInstalled(extension_.get(), Extension::ENABLED, syncer::StringOrdinal()); } virtual void Verify() OVERRIDE { syncer::StringOrdinal launch_ordinal = extension_sorting()->GetAppLaunchOrdinal(extension_->id()); syncer::StringOrdinal page_ordinal = syncer::StringOrdinal::CreateInitialOrdinal(); // Extension should have been assigned a valid StringOrdinal. EXPECT_TRUE(launch_ordinal.IsValid()); EXPECT_TRUE(launch_ordinal.LessThan( extension_sorting()->CreateNextAppLaunchOrdinal(page_ordinal))); // Set a new launch ordinal of and verify it comes after. extension_sorting()->SetAppLaunchOrdinal( extension_->id(), extension_sorting()->CreateNextAppLaunchOrdinal(page_ordinal)); syncer::StringOrdinal new_launch_ordinal = extension_sorting()->GetAppLaunchOrdinal(extension_->id()); EXPECT_TRUE(launch_ordinal.LessThan(new_launch_ordinal)); // This extension doesn't exist, so it should return an invalid // StringOrdinal. syncer::StringOrdinal invalid_app_launch_ordinal = extension_sorting()->GetAppLaunchOrdinal("foo"); EXPECT_FALSE(invalid_app_launch_ordinal.IsValid()); EXPECT_EQ(-1, extension_sorting()->PageStringOrdinalAsInteger( invalid_app_launch_ordinal)); // The second page doesn't have any apps so its next launch ordinal should // be the first launch ordinal. syncer::StringOrdinal next_page = page_ordinal.CreateAfter(); syncer::StringOrdinal next_page_app_launch_ordinal = extension_sorting()->CreateNextAppLaunchOrdinal(next_page); EXPECT_TRUE(next_page_app_launch_ordinal.Equals( extension_sorting()->CreateFirstAppLaunchOrdinal(next_page))); } private: scoped_refptr<Extension> extension_; }; TEST_F(ExtensionSortingAppLaunchOrdinal, ExtensionSortingAppLaunchOrdinal) {} class ExtensionSortingPageOrdinal : public ExtensionSortingTest { public: virtual void Initialize() OVERRIDE { extension_ = prefs_.AddApp("page_ordinal"); // Install with a page preference. first_page_ = syncer::StringOrdinal::CreateInitialOrdinal(); prefs()->OnExtensionInstalled(extension_.get(), Extension::ENABLED, first_page_); EXPECT_TRUE(first_page_.Equals( extension_sorting()->GetPageOrdinal(extension_->id()))); EXPECT_EQ(0, extension_sorting()->PageStringOrdinalAsInteger(first_page_)); scoped_refptr<Extension> extension2 = prefs_.AddApp("page_ordinal_2"); // Install without any page preference. prefs()->OnExtensionInstalled(extension2.get(), Extension::ENABLED, syncer::StringOrdinal()); EXPECT_TRUE(first_page_.Equals( extension_sorting()->GetPageOrdinal(extension2->id()))); } virtual void Verify() OVERRIDE { // Set the page ordinal. syncer::StringOrdinal new_page = first_page_.CreateAfter(); extension_sorting()->SetPageOrdinal(extension_->id(), new_page); // Verify the page ordinal. EXPECT_TRUE( new_page.Equals(extension_sorting()->GetPageOrdinal(extension_->id()))); EXPECT_EQ(1, extension_sorting()->PageStringOrdinalAsInteger(new_page)); // This extension doesn't exist, so it should return an invalid // StringOrdinal. EXPECT_FALSE(extension_sorting()->GetPageOrdinal("foo").IsValid()); } private: syncer::StringOrdinal first_page_; scoped_refptr<Extension> extension_; }; TEST_F(ExtensionSortingPageOrdinal, ExtensionSortingPageOrdinal) {} // Ensure that ExtensionSorting is able to properly initialize off a set // of old page and app launch indices and properly convert them. class ExtensionSortingInitialize : public extensions::ExtensionPrefsPrepopulatedTest { public: ExtensionSortingInitialize() {} virtual ~ExtensionSortingInitialize() {} virtual void Initialize() OVERRIDE { // A preference determining the order of which the apps appear on the NTP. const char kPrefAppLaunchIndexDeprecated[] = "app_launcher_index"; // A preference determining the page on which an app appears in the NTP. const char kPrefPageIndexDeprecated[] = "page_index"; // Setup the deprecated preferences. ExtensionScopedPrefs* scoped_prefs = static_cast<ExtensionScopedPrefs*>(prefs()); scoped_prefs->UpdateExtensionPref(ext1_->id(), kPrefAppLaunchIndexDeprecated, Value::CreateIntegerValue(0)); scoped_prefs->UpdateExtensionPref(ext1_->id(), kPrefPageIndexDeprecated, Value::CreateIntegerValue(0)); scoped_prefs->UpdateExtensionPref(ext2_->id(), kPrefAppLaunchIndexDeprecated, Value::CreateIntegerValue(1)); scoped_prefs->UpdateExtensionPref(ext2_->id(), kPrefPageIndexDeprecated, Value::CreateIntegerValue(0)); scoped_prefs->UpdateExtensionPref(ext3_->id(), kPrefAppLaunchIndexDeprecated, Value::CreateIntegerValue(0)); scoped_prefs->UpdateExtensionPref(ext3_->id(), kPrefPageIndexDeprecated, Value::CreateIntegerValue(1)); // We insert the ids in reserve order so that we have to deal with the // element on the 2nd page before the 1st page is seen. extensions::ExtensionIdList ids; ids.push_back(ext3_->id()); ids.push_back(ext2_->id()); ids.push_back(ext1_->id()); prefs()->extension_sorting()->Initialize(ids); } virtual void Verify() OVERRIDE { syncer::StringOrdinal first_ordinal = syncer::StringOrdinal::CreateInitialOrdinal(); ExtensionSorting* extension_sorting = prefs()->extension_sorting(); EXPECT_TRUE(first_ordinal.Equals( extension_sorting->GetAppLaunchOrdinal(ext1_->id()))); EXPECT_TRUE(first_ordinal.LessThan( extension_sorting->GetAppLaunchOrdinal(ext2_->id()))); EXPECT_TRUE(first_ordinal.Equals( extension_sorting->GetAppLaunchOrdinal(ext3_->id()))); EXPECT_TRUE(first_ordinal.Equals( extension_sorting->GetPageOrdinal(ext1_->id()))); EXPECT_TRUE(first_ordinal.Equals( extension_sorting->GetPageOrdinal(ext2_->id()))); EXPECT_TRUE(first_ordinal.LessThan( extension_sorting->GetPageOrdinal(ext3_->id()))); } }; TEST_F(ExtensionSortingInitialize, ExtensionSortingInitialize) {} // Make sure that initialization still works when no extensions are present // (i.e. make sure that the web store icon is still loaded into the map). class ExtensionSortingInitializeWithNoApps : public extensions::ExtensionPrefsPrepopulatedTest { public: ExtensionSortingInitializeWithNoApps() {} virtual ~ExtensionSortingInitializeWithNoApps() {} virtual void Initialize() OVERRIDE { ExtensionSorting* extension_sorting = prefs()->extension_sorting(); // Make sure that the web store has valid ordinals. syncer::StringOrdinal initial_ordinal = syncer::StringOrdinal::CreateInitialOrdinal(); extension_sorting->SetPageOrdinal(extension_misc::kWebStoreAppId, initial_ordinal); extension_sorting->SetAppLaunchOrdinal(extension_misc::kWebStoreAppId, initial_ordinal); extensions::ExtensionIdList ids; extension_sorting->Initialize(ids); } virtual void Verify() OVERRIDE { ExtensionSorting* extension_sorting = prefs()->extension_sorting(); syncer::StringOrdinal page = extension_sorting->GetPageOrdinal(extension_misc::kWebStoreAppId); EXPECT_TRUE(page.IsValid()); ExtensionSorting::PageOrdinalMap::iterator page_it = extension_sorting->ntp_ordinal_map_.find(page); EXPECT_TRUE(page_it != extension_sorting->ntp_ordinal_map_.end()); syncer::StringOrdinal app_launch = extension_sorting->GetPageOrdinal(extension_misc::kWebStoreAppId); EXPECT_TRUE(app_launch.IsValid()); ExtensionSorting::AppLaunchOrdinalMap::iterator app_launch_it = page_it->second.find(app_launch); EXPECT_TRUE(app_launch_it != page_it->second.end()); } }; TEST_F(ExtensionSortingInitializeWithNoApps, ExtensionSortingInitializeWithNoApps) {} // Tests the application index to ordinal migration code for values that // shouldn't be converted. This should be removed when the migrate code // is taken out. // http://crbug.com/107376 class ExtensionSortingMigrateAppIndexInvalid : public extensions::ExtensionPrefsPrepopulatedTest { public: ExtensionSortingMigrateAppIndexInvalid() {} virtual ~ExtensionSortingMigrateAppIndexInvalid() {} virtual void Initialize() OVERRIDE { // A preference determining the order of which the apps appear on the NTP. const char kPrefAppLaunchIndexDeprecated[] = "app_launcher_index"; // A preference determining the page on which an app appears in the NTP. const char kPrefPageIndexDeprecated[] = "page_index"; // Setup the deprecated preference. ExtensionScopedPrefs* scoped_prefs = static_cast<ExtensionScopedPrefs*>(prefs()); scoped_prefs->UpdateExtensionPref(ext1_->id(), kPrefAppLaunchIndexDeprecated, Value::CreateIntegerValue(0)); scoped_prefs->UpdateExtensionPref(ext1_->id(), kPrefPageIndexDeprecated, Value::CreateIntegerValue(-1)); extensions::ExtensionIdList ids; ids.push_back(ext1_->id()); prefs()->extension_sorting()->Initialize(ids); } virtual void Verify() OVERRIDE { // Make sure that the invalid page_index wasn't converted over. EXPECT_FALSE(prefs()->extension_sorting()->GetAppLaunchOrdinal( ext1_->id()).IsValid()); } }; TEST_F(ExtensionSortingMigrateAppIndexInvalid, ExtensionSortingMigrateAppIndexInvalid) {} class ExtensionSortingFixNTPCollisionsAllCollide : public extensions::ExtensionPrefsPrepopulatedTest { public: ExtensionSortingFixNTPCollisionsAllCollide() {} virtual ~ExtensionSortingFixNTPCollisionsAllCollide() {} virtual void Initialize() OVERRIDE { repeated_ordinal_ = syncer::StringOrdinal::CreateInitialOrdinal(); ExtensionSorting* extension_sorting = prefs()->extension_sorting(); extension_sorting->SetAppLaunchOrdinal(ext1_->id(), repeated_ordinal_); extension_sorting->SetPageOrdinal(ext1_->id(), repeated_ordinal_); extension_sorting->SetAppLaunchOrdinal(ext2_->id(), repeated_ordinal_); extension_sorting->SetPageOrdinal(ext2_->id(), repeated_ordinal_); extension_sorting->SetAppLaunchOrdinal(ext3_->id(), repeated_ordinal_); extension_sorting->SetPageOrdinal(ext3_->id(), repeated_ordinal_); extension_sorting->FixNTPOrdinalCollisions(); } virtual void Verify() OVERRIDE { ExtensionSorting* extension_sorting = prefs()->extension_sorting(); syncer::StringOrdinal ext1_app_launch = extension_sorting->GetAppLaunchOrdinal(ext1_->id()); syncer::StringOrdinal ext2_app_launch = extension_sorting->GetAppLaunchOrdinal(ext2_->id()); syncer::StringOrdinal ext3_app_launch = extension_sorting->GetAppLaunchOrdinal(ext3_->id()); // The overlapping extensions should have be adjusted so that they are // sorted by their id. EXPECT_EQ(ext1_->id() < ext2_->id(), ext1_app_launch.LessThan(ext2_app_launch)); EXPECT_EQ(ext1_->id() < ext3_->id(), ext1_app_launch.LessThan(ext3_app_launch)); EXPECT_EQ(ext2_->id() < ext3_->id(), ext2_app_launch.LessThan(ext3_app_launch)); // The page ordinal should be unchanged. EXPECT_TRUE(extension_sorting->GetPageOrdinal(ext1_->id()).Equals( repeated_ordinal_)); EXPECT_TRUE(extension_sorting->GetPageOrdinal(ext2_->id()).Equals( repeated_ordinal_)); EXPECT_TRUE(extension_sorting->GetPageOrdinal(ext3_->id()).Equals( repeated_ordinal_)); } private: syncer::StringOrdinal repeated_ordinal_; }; TEST_F(ExtensionSortingFixNTPCollisionsAllCollide, ExtensionSortingFixNTPCollisionsAllCollide) {} class ExtensionSortingFixNTPCollisionsSomeCollideAtStart : public extensions::ExtensionPrefsPrepopulatedTest { public: ExtensionSortingFixNTPCollisionsSomeCollideAtStart() {} virtual ~ExtensionSortingFixNTPCollisionsSomeCollideAtStart() {} virtual void Initialize() OVERRIDE { first_ordinal_ = syncer::StringOrdinal::CreateInitialOrdinal(); syncer::StringOrdinal second_ordinal = first_ordinal_.CreateAfter(); ExtensionSorting* extension_sorting = prefs()->extension_sorting(); // Have the first two extension in the same position, with a third // (non-colliding) extension after. extension_sorting->SetAppLaunchOrdinal(ext1_->id(), first_ordinal_); extension_sorting->SetPageOrdinal(ext1_->id(), first_ordinal_); extension_sorting->SetAppLaunchOrdinal(ext2_->id(), first_ordinal_); extension_sorting->SetPageOrdinal(ext2_->id(), first_ordinal_); extension_sorting->SetAppLaunchOrdinal(ext3_->id(), second_ordinal); extension_sorting->SetPageOrdinal(ext3_->id(), first_ordinal_); extension_sorting->FixNTPOrdinalCollisions(); } virtual void Verify() OVERRIDE { ExtensionSorting* extension_sorting = prefs()->extension_sorting(); syncer::StringOrdinal ext1_app_launch = extension_sorting->GetAppLaunchOrdinal(ext1_->id()); syncer::StringOrdinal ext2_app_launch = extension_sorting->GetAppLaunchOrdinal(ext2_->id()); syncer::StringOrdinal ext3_app_launch = extension_sorting->GetAppLaunchOrdinal(ext3_->id()); // The overlapping extensions should have be adjusted so that they are // sorted by their id, but they both should be before ext3, which wasn't // overlapping. EXPECT_EQ(ext1_->id() < ext2_->id(), ext1_app_launch.LessThan(ext2_app_launch)); EXPECT_TRUE(ext1_app_launch.LessThan(ext3_app_launch)); EXPECT_TRUE(ext2_app_launch.LessThan(ext3_app_launch)); // The page ordinal should be unchanged. EXPECT_TRUE(extension_sorting->GetPageOrdinal(ext1_->id()).Equals( first_ordinal_)); EXPECT_TRUE(extension_sorting->GetPageOrdinal(ext2_->id()).Equals( first_ordinal_)); EXPECT_TRUE(extension_sorting->GetPageOrdinal(ext3_->id()).Equals( first_ordinal_)); } private: syncer::StringOrdinal first_ordinal_; }; TEST_F(ExtensionSortingFixNTPCollisionsSomeCollideAtStart, ExtensionSortingFixNTPCollisionsSomeCollideAtStart) {} class ExtensionSortingFixNTPCollisionsSomeCollideAtEnd : public extensions::ExtensionPrefsPrepopulatedTest { public: ExtensionSortingFixNTPCollisionsSomeCollideAtEnd() {} virtual ~ExtensionSortingFixNTPCollisionsSomeCollideAtEnd() {} virtual void Initialize() OVERRIDE { first_ordinal_ = syncer::StringOrdinal::CreateInitialOrdinal(); syncer::StringOrdinal second_ordinal = first_ordinal_.CreateAfter(); ExtensionSorting* extension_sorting = prefs()->extension_sorting(); // Have the first extension in a non-colliding position, followed by two // two extension in the same position. extension_sorting->SetAppLaunchOrdinal(ext1_->id(), first_ordinal_); extension_sorting->SetPageOrdinal(ext1_->id(), first_ordinal_); extension_sorting->SetAppLaunchOrdinal(ext2_->id(), second_ordinal); extension_sorting->SetPageOrdinal(ext2_->id(), first_ordinal_); extension_sorting->SetAppLaunchOrdinal(ext3_->id(), second_ordinal); extension_sorting->SetPageOrdinal(ext3_->id(), first_ordinal_); extension_sorting->FixNTPOrdinalCollisions(); } virtual void Verify() OVERRIDE { ExtensionSorting* extension_sorting = prefs()->extension_sorting(); syncer::StringOrdinal ext1_app_launch = extension_sorting->GetAppLaunchOrdinal(ext1_->id()); syncer::StringOrdinal ext2_app_launch = extension_sorting->GetAppLaunchOrdinal(ext2_->id()); syncer::StringOrdinal ext3_app_launch = extension_sorting->GetAppLaunchOrdinal(ext3_->id()); // The overlapping extensions should have be adjusted so that they are // sorted by their id, but they both should be after ext1, which wasn't // overlapping. EXPECT_TRUE(ext1_app_launch.LessThan(ext2_app_launch)); EXPECT_TRUE(ext1_app_launch.LessThan(ext3_app_launch)); EXPECT_EQ(ext2_->id() < ext3_->id(), ext2_app_launch.LessThan(ext3_app_launch)); // The page ordinal should be unchanged. EXPECT_TRUE(extension_sorting->GetPageOrdinal(ext1_->id()).Equals( first_ordinal_)); EXPECT_TRUE(extension_sorting->GetPageOrdinal(ext2_->id()).Equals( first_ordinal_)); EXPECT_TRUE(extension_sorting->GetPageOrdinal(ext3_->id()).Equals( first_ordinal_)); } private: syncer::StringOrdinal first_ordinal_; }; TEST_F(ExtensionSortingFixNTPCollisionsSomeCollideAtEnd, ExtensionSortingFixNTPCollisionsSomeCollideAtEnd) {} class ExtensionSortingFixNTPCollisionsTwoCollisions : public extensions::ExtensionPrefsPrepopulatedTest { public: ExtensionSortingFixNTPCollisionsTwoCollisions() {} virtual ~ExtensionSortingFixNTPCollisionsTwoCollisions() {} virtual void Initialize() OVERRIDE { first_ordinal_ = syncer::StringOrdinal::CreateInitialOrdinal(); syncer::StringOrdinal second_ordinal = first_ordinal_.CreateAfter(); ExtensionSorting* extension_sorting = prefs()->extension_sorting(); // Have two extensions colliding, followed by two more colliding extensions. extension_sorting->SetAppLaunchOrdinal(ext1_->id(), first_ordinal_); extension_sorting->SetPageOrdinal(ext1_->id(), first_ordinal_); extension_sorting->SetAppLaunchOrdinal(ext2_->id(), first_ordinal_); extension_sorting->SetPageOrdinal(ext2_->id(), first_ordinal_); extension_sorting->SetAppLaunchOrdinal(ext3_->id(), second_ordinal); extension_sorting->SetPageOrdinal(ext3_->id(), first_ordinal_); extension_sorting->SetAppLaunchOrdinal(ext4_->id(), second_ordinal); extension_sorting->SetPageOrdinal(ext4_->id(), first_ordinal_); extension_sorting->FixNTPOrdinalCollisions(); } virtual void Verify() OVERRIDE { ExtensionSorting* extension_sorting = prefs()->extension_sorting(); syncer::StringOrdinal ext1_app_launch = extension_sorting->GetAppLaunchOrdinal(ext1_->id()); syncer::StringOrdinal ext2_app_launch = extension_sorting->GetAppLaunchOrdinal(ext2_->id()); syncer::StringOrdinal ext3_app_launch = extension_sorting->GetAppLaunchOrdinal(ext3_->id()); syncer::StringOrdinal ext4_app_launch = extension_sorting->GetAppLaunchOrdinal(ext4_->id()); // The overlapping extensions should have be adjusted so that they are // sorted by their id, with |ext1| and |ext2| appearing before |ext3| and // |ext4|. EXPECT_TRUE(ext1_app_launch.LessThan(ext3_app_launch)); EXPECT_TRUE(ext1_app_launch.LessThan(ext4_app_launch)); EXPECT_TRUE(ext2_app_launch.LessThan(ext3_app_launch)); EXPECT_TRUE(ext2_app_launch.LessThan(ext4_app_launch)); EXPECT_EQ(ext1_->id() < ext2_->id(), ext1_app_launch.LessThan(ext2_app_launch)); EXPECT_EQ(ext3_->id() < ext4_->id(), ext3_app_launch.LessThan(ext4_app_launch)); // The page ordinal should be unchanged. EXPECT_TRUE(extension_sorting->GetPageOrdinal(ext1_->id()).Equals( first_ordinal_)); EXPECT_TRUE(extension_sorting->GetPageOrdinal(ext2_->id()).Equals( first_ordinal_)); EXPECT_TRUE(extension_sorting->GetPageOrdinal(ext3_->id()).Equals( first_ordinal_)); EXPECT_TRUE(extension_sorting->GetPageOrdinal(ext4_->id()).Equals( first_ordinal_)); } private: syncer::StringOrdinal first_ordinal_; }; TEST_F(ExtensionSortingFixNTPCollisionsTwoCollisions, ExtensionSortingFixNTPCollisionsTwoCollisions) {} class ExtensionSortingEnsureValidOrdinals : public extensions::ExtensionPrefsPrepopulatedTest { public : ExtensionSortingEnsureValidOrdinals() {} ~ExtensionSortingEnsureValidOrdinals() {} virtual void Initialize() {} virtual void Verify() { ExtensionSorting* extension_sorting = prefs()->extension_sorting(); // Give ext1 invalid ordinals and then check that EnsureValidOrdinals fixes // them. extension_sorting->SetAppLaunchOrdinal(ext1_->id(), syncer::StringOrdinal()); extension_sorting->SetPageOrdinal(ext1_->id(), syncer::StringOrdinal()); extension_sorting->EnsureValidOrdinals(ext1_->id(), syncer::StringOrdinal()); EXPECT_TRUE(extension_sorting->GetAppLaunchOrdinal(ext1_->id()).IsValid()); EXPECT_TRUE(extension_sorting->GetPageOrdinal(ext1_->id()).IsValid()); } }; TEST_F(ExtensionSortingEnsureValidOrdinals, ExtensionSortingEnsureValidOrdinals) {} class ExtensionSortingPageOrdinalMapping : public extensions::ExtensionPrefsPrepopulatedTest { public: ExtensionSortingPageOrdinalMapping() {} virtual ~ExtensionSortingPageOrdinalMapping() {} virtual void Initialize() OVERRIDE {} virtual void Verify() OVERRIDE { std::string ext_1 = "ext_1"; std::string ext_2 = "ext_2"; ExtensionSorting* extension_sorting = prefs()->extension_sorting(); syncer::StringOrdinal first_ordinal = syncer::StringOrdinal::CreateInitialOrdinal(); // Ensure attempting to removing a mapping with an invalid page doesn't // modify the map. EXPECT_TRUE(extension_sorting->ntp_ordinal_map_.empty()); extension_sorting->RemoveOrdinalMapping( ext_1, first_ordinal, first_ordinal); EXPECT_TRUE(extension_sorting->ntp_ordinal_map_.empty()); // Add new mappings. extension_sorting->AddOrdinalMapping(ext_1, first_ordinal, first_ordinal); extension_sorting->AddOrdinalMapping(ext_2, first_ordinal, first_ordinal); EXPECT_EQ(1U, extension_sorting->ntp_ordinal_map_.size()); EXPECT_EQ(2U, extension_sorting->ntp_ordinal_map_[first_ordinal].size()); ExtensionSorting::AppLaunchOrdinalMap::iterator it = extension_sorting->ntp_ordinal_map_[first_ordinal].find(first_ordinal); EXPECT_EQ(ext_1, it->second); ++it; EXPECT_EQ(ext_2, it->second); extension_sorting->RemoveOrdinalMapping(ext_1, first_ordinal, first_ordinal); EXPECT_EQ(1U, extension_sorting->ntp_ordinal_map_.size()); EXPECT_EQ(1U, extension_sorting->ntp_ordinal_map_[first_ordinal].size()); it = extension_sorting->ntp_ordinal_map_[first_ordinal].find( first_ordinal); EXPECT_EQ(ext_2, it->second); // Ensure that attempting to remove an extension with a valid page and app // launch ordinals, but a unused id has no effect. extension_sorting->RemoveOrdinalMapping( "invalid_ext", first_ordinal, first_ordinal); EXPECT_EQ(1U, extension_sorting->ntp_ordinal_map_.size()); EXPECT_EQ(1U, extension_sorting->ntp_ordinal_map_[first_ordinal].size()); it = extension_sorting->ntp_ordinal_map_[first_ordinal].find( first_ordinal); EXPECT_EQ(ext_2, it->second); } }; TEST_F(ExtensionSortingPageOrdinalMapping, ExtensionSortingPageOrdinalMapping) {} class ExtensionSortingPreinstalledAppsBase : public extensions::ExtensionPrefsPrepopulatedTest { public: ExtensionSortingPreinstalledAppsBase() { DictionaryValue simple_dict; simple_dict.SetString(keys::kVersion, "1.0.0.0"); simple_dict.SetString(keys::kName, "unused"); simple_dict.SetString(keys::kApp, "true"); simple_dict.SetString(keys::kLaunchLocalPath, "fake.html"); std::string error; app1_scoped_ = Extension::Create( prefs_.temp_dir().AppendASCII("app1_"), Extension::EXTERNAL_PREF, simple_dict, Extension::NO_FLAGS, &error); prefs()->OnExtensionInstalled(app1_scoped_.get(), Extension::ENABLED, syncer::StringOrdinal()); app2_scoped_ = Extension::Create( prefs_.temp_dir().AppendASCII("app2_"), Extension::EXTERNAL_PREF, simple_dict, Extension::NO_FLAGS, &error); prefs()->OnExtensionInstalled(app2_scoped_.get(), Extension::ENABLED, syncer::StringOrdinal()); app1_ = app1_scoped_.get(); app2_ = app2_scoped_.get(); } virtual ~ExtensionSortingPreinstalledAppsBase() {} protected: // Weak references, for convenience. Extension* app1_; Extension* app2_; private: scoped_refptr<Extension> app1_scoped_; scoped_refptr<Extension> app2_scoped_; }; class ExtensionSortingGetMinOrMaxAppLaunchOrdinalsOnPage : public ExtensionSortingPreinstalledAppsBase { public: ExtensionSortingGetMinOrMaxAppLaunchOrdinalsOnPage() {} virtual ~ExtensionSortingGetMinOrMaxAppLaunchOrdinalsOnPage() {} virtual void Initialize() OVERRIDE {} virtual void Verify() OVERRIDE { syncer::StringOrdinal page = syncer::StringOrdinal::CreateInitialOrdinal(); ExtensionSorting* extension_sorting = prefs()->extension_sorting(); syncer::StringOrdinal min = extension_sorting->GetMinOrMaxAppLaunchOrdinalsOnPage( page, ExtensionSorting::MIN_ORDINAL); syncer::StringOrdinal max = extension_sorting->GetMinOrMaxAppLaunchOrdinalsOnPage( page, ExtensionSorting::MAX_ORDINAL); EXPECT_TRUE(min.IsValid()); EXPECT_TRUE(max.IsValid()); EXPECT_TRUE(min.LessThan(max)); // Ensure that the min and max values aren't set for empty pages. min = syncer::StringOrdinal(); max = syncer::StringOrdinal(); syncer::StringOrdinal empty_page = page.CreateAfter(); EXPECT_FALSE(min.IsValid()); EXPECT_FALSE(max.IsValid()); min = extension_sorting->GetMinOrMaxAppLaunchOrdinalsOnPage( empty_page, ExtensionSorting::MIN_ORDINAL); max = extension_sorting->GetMinOrMaxAppLaunchOrdinalsOnPage( empty_page, ExtensionSorting::MAX_ORDINAL); EXPECT_FALSE(min.IsValid()); EXPECT_FALSE(max.IsValid()); } }; TEST_F(ExtensionSortingGetMinOrMaxAppLaunchOrdinalsOnPage, ExtensionSortingGetMinOrMaxAppLaunchOrdinalsOnPage) {} // Make sure that empty pages aren't removed from the integer to ordinal // mapping. See http://crbug.com/109802 for details. class ExtensionSortingKeepEmptyStringOrdinalPages : public ExtensionSortingPreinstalledAppsBase { public: ExtensionSortingKeepEmptyStringOrdinalPages() {} virtual ~ExtensionSortingKeepEmptyStringOrdinalPages() {} virtual void Initialize() OVERRIDE { ExtensionSorting* extension_sorting = prefs()->extension_sorting(); syncer::StringOrdinal first_page = syncer::StringOrdinal::CreateInitialOrdinal(); extension_sorting->SetPageOrdinal(app1_->id(), first_page); EXPECT_EQ(0, extension_sorting->PageStringOrdinalAsInteger(first_page)); last_page_ = first_page.CreateAfter(); extension_sorting->SetPageOrdinal(app2_->id(), last_page_); EXPECT_EQ(1, extension_sorting->PageStringOrdinalAsInteger(last_page_)); // Move the second app to create an empty page. extension_sorting->SetPageOrdinal(app2_->id(), first_page); EXPECT_EQ(0, extension_sorting->PageStringOrdinalAsInteger(first_page)); } virtual void Verify() OVERRIDE { ExtensionSorting* extension_sorting = prefs()->extension_sorting(); // Move the second app to a new empty page at the end, skipping over // the current empty page. last_page_ = last_page_.CreateAfter(); extension_sorting->SetPageOrdinal(app2_->id(), last_page_); EXPECT_EQ(2, extension_sorting->PageStringOrdinalAsInteger(last_page_)); EXPECT_TRUE( last_page_.Equals(extension_sorting->PageIntegerAsStringOrdinal(2))); } private: syncer::StringOrdinal last_page_; }; TEST_F(ExtensionSortingKeepEmptyStringOrdinalPages, ExtensionSortingKeepEmptyStringOrdinalPages) {} class ExtensionSortingMakesFillerOrdinals : public ExtensionSortingPreinstalledAppsBase { public: ExtensionSortingMakesFillerOrdinals() {} virtual ~ExtensionSortingMakesFillerOrdinals() {} virtual void Initialize() OVERRIDE { ExtensionSorting* extension_sorting = prefs()->extension_sorting(); syncer::StringOrdinal first_page = syncer::StringOrdinal::CreateInitialOrdinal(); extension_sorting->SetPageOrdinal(app1_->id(), first_page); EXPECT_EQ(0, extension_sorting->PageStringOrdinalAsInteger(first_page)); } virtual void Verify() OVERRIDE { ExtensionSorting* extension_sorting = prefs()->extension_sorting(); // Because the UI can add an unlimited number of empty pages without an app // on them, this test simulates dropping of an app on the 1st and 4th empty // pages (3rd and 6th pages by index) to ensure we don't crash and that // filler ordinals are created as needed. See: http://crbug.com/122214 syncer::StringOrdinal page_three = extension_sorting->PageIntegerAsStringOrdinal(2); extension_sorting->SetPageOrdinal(app1_->id(), page_three); EXPECT_EQ(2, extension_sorting->PageStringOrdinalAsInteger(page_three)); syncer::StringOrdinal page_six = extension_sorting->PageIntegerAsStringOrdinal(5); extension_sorting->SetPageOrdinal(app1_->id(), page_six); EXPECT_EQ(5, extension_sorting->PageStringOrdinalAsInteger(page_six)); } }; TEST_F(ExtensionSortingMakesFillerOrdinals, ExtensionSortingMakesFillerOrdinals) {} class ExtensionSortingDefaultOrdinalsBase : public ExtensionSortingTest { public: ExtensionSortingDefaultOrdinalsBase() {} virtual ~ExtensionSortingDefaultOrdinalsBase() {} virtual void Initialize() OVERRIDE { app_ = CreateApp("app"); InitDefaultOrdinals(); ExtensionSorting* extension_sorting = prefs()->extension_sorting(); ExtensionSorting::AppOrdinalsMap& sorting_defaults = extension_sorting->default_ordinals_; sorting_defaults[app_->id()].page_ordinal = default_page_ordinal_; sorting_defaults[app_->id()].app_launch_ordinal = default_app_launch_ordinal_; SetupUserOrdinals(); InstallApps(); } protected: scoped_refptr<Extension> CreateApp(const std::string& name) { DictionaryValue simple_dict; simple_dict.SetString(keys::kVersion, "1.0.0.0"); simple_dict.SetString(keys::kName, name); simple_dict.SetString(keys::kApp, "true"); simple_dict.SetString(keys::kLaunchLocalPath, "fake.html"); std::string errors; scoped_refptr<Extension> app = Extension::Create( prefs_.temp_dir().AppendASCII(name), Extension::EXTERNAL_PREF, simple_dict, Extension::NO_FLAGS, &errors); EXPECT_TRUE(app) << errors; EXPECT_TRUE(Extension::IdIsValid(app->id())); return app; } void InitDefaultOrdinals() { default_page_ordinal_ = syncer::StringOrdinal::CreateInitialOrdinal().CreateAfter(); default_app_launch_ordinal_ = syncer::StringOrdinal::CreateInitialOrdinal().CreateBefore(); } virtual void SetupUserOrdinals() {} virtual void InstallApps() { prefs()->OnExtensionInstalled(app_.get(), Extension::ENABLED, syncer::StringOrdinal()); } scoped_refptr<Extension> app_; syncer::StringOrdinal default_page_ordinal_; syncer::StringOrdinal default_app_launch_ordinal_; }; // Tests that the app gets its default ordinals. class ExtensionSortingDefaultOrdinals : public ExtensionSortingDefaultOrdinalsBase { public: ExtensionSortingDefaultOrdinals() {} virtual ~ExtensionSortingDefaultOrdinals() {} virtual void Verify() OVERRIDE { ExtensionSorting* extension_sorting = prefs()->extension_sorting(); EXPECT_TRUE(extension_sorting->GetPageOrdinal(app_->id()).Equals( default_page_ordinal_)); EXPECT_TRUE(extension_sorting->GetAppLaunchOrdinal(app_->id()).Equals( default_app_launch_ordinal_)); } }; TEST_F(ExtensionSortingDefaultOrdinals, ExtensionSortingDefaultOrdinals) {} // Tests that the default page ordinal is overridden by install page ordinal. class ExtensionSortingDefaultOrdinalOverriddenByInstallPage : public ExtensionSortingDefaultOrdinalsBase { public: ExtensionSortingDefaultOrdinalOverriddenByInstallPage() {} virtual ~ExtensionSortingDefaultOrdinalOverriddenByInstallPage() {} virtual void Verify() OVERRIDE { ExtensionSorting* extension_sorting = prefs()->extension_sorting(); EXPECT_FALSE(extension_sorting->GetPageOrdinal(app_->id()).Equals( default_page_ordinal_)); EXPECT_TRUE(extension_sorting->GetPageOrdinal(app_->id()).Equals( install_page_)); } protected: virtual void InstallApps() OVERRIDE { install_page_ = default_page_ordinal_.CreateAfter(); prefs()->OnExtensionInstalled(app_.get(), Extension::ENABLED, install_page_); } private: syncer::StringOrdinal install_page_; }; TEST_F(ExtensionSortingDefaultOrdinalOverriddenByInstallPage, ExtensionSortingDefaultOrdinalOverriddenByInstallPage) {} // Tests that the default ordinals are overridden by user values. class ExtensionSortingDefaultOrdinalOverriddenByUserValue : public ExtensionSortingDefaultOrdinalsBase { public: ExtensionSortingDefaultOrdinalOverriddenByUserValue() {} virtual ~ExtensionSortingDefaultOrdinalOverriddenByUserValue() {} virtual void Verify() OVERRIDE { ExtensionSorting* extension_sorting = prefs()->extension_sorting(); EXPECT_TRUE(extension_sorting->GetPageOrdinal(app_->id()).Equals( user_page_ordinal_)); EXPECT_TRUE(extension_sorting->GetAppLaunchOrdinal(app_->id()).Equals( user_app_launch_ordinal_)); } protected: virtual void SetupUserOrdinals() { user_page_ordinal_ = default_page_ordinal_.CreateAfter(); user_app_launch_ordinal_ = default_app_launch_ordinal_.CreateBefore(); ExtensionSorting* extension_sorting = prefs()->extension_sorting(); extension_sorting->SetPageOrdinal(app_->id(), user_page_ordinal_); extension_sorting->SetAppLaunchOrdinal(app_->id(), user_app_launch_ordinal_); } private: syncer::StringOrdinal user_page_ordinal_; syncer::StringOrdinal user_app_launch_ordinal_; }; TEST_F(ExtensionSortingDefaultOrdinalOverriddenByUserValue, ExtensionSortingDefaultOrdinalOverriddenByUserValue) {} // Tests that the default app launch ordinal is changed to avoid collision. class ExtensionSortingDefaultOrdinalNoCollision : public ExtensionSortingDefaultOrdinalsBase { public: ExtensionSortingDefaultOrdinalNoCollision() {} virtual ~ExtensionSortingDefaultOrdinalNoCollision() {} virtual void Verify() OVERRIDE { ExtensionSorting* extension_sorting = prefs()->extension_sorting(); // Use the default page. EXPECT_TRUE(extension_sorting->GetPageOrdinal(app_->id()).Equals( default_page_ordinal_)); // Not using the default app launch ordinal because of the collision. EXPECT_FALSE(extension_sorting->GetAppLaunchOrdinal(app_->id()).Equals( default_app_launch_ordinal_)); } protected: virtual void SetupUserOrdinals() { other_app_ = prefs_.AddApp("other_app"); // Creates a collision. ExtensionSorting* extension_sorting = prefs()->extension_sorting(); extension_sorting->SetPageOrdinal(other_app_->id(), default_page_ordinal_); extension_sorting->SetAppLaunchOrdinal(other_app_->id(), default_app_launch_ordinal_); yet_another_app_ = prefs_.AddApp("yet_aother_app"); extension_sorting->SetPageOrdinal(yet_another_app_->id(), default_page_ordinal_); extension_sorting->SetAppLaunchOrdinal(yet_another_app_->id(), default_app_launch_ordinal_); } private: scoped_refptr<Extension> other_app_; scoped_refptr<Extension> yet_another_app_; }; TEST_F(ExtensionSortingDefaultOrdinalNoCollision, ExtensionSortingDefaultOrdinalNoCollision) {}
[ "rjogrady@google.com" ]
rjogrady@google.com
f2eb6dadf6d52a0fbbb57287d96d1c4140932eb2
88e364025c322b88882efb51f5da16f1274ac15a
/acm/118.cpp
fa1e7e3ee229046e924c7872a7e706b8676d96fa
[]
no_license
koukaipan/problem_solving
b3613db330841e33965b7d621a752a8a96e1e0a9
c71da70f538401c7282352d84ad63d58db184ae7
refs/heads/master
2022-06-22T00:49:07.308185
2022-05-15T07:47:21
2022-05-15T07:47:21
195,614,818
0
0
null
null
null
null
BIG5
C++
false
false
1,553
cpp
#include <stdio.h> #include <string.h> #define NORTH 0 #define EAST 1 #define SOUTH 2 #define WEST 3 #define MAX 51 main() { int up_bound, right_bound; bool map[MAX][MAX]; bool lost; char a, b, i; int dir; char command[102]; int x, y; /* current position */ const int move[4][2] = {{0,1}, {1,0}, {0,-1}, {-1,0}}; freopen("118.txt", "r", stdin); freopen("118_out.txt", "w", stdout); memset(map, 0, sizeof(bool)*MAX*MAX); scanf("%d %d", &up_bound, &right_bound); while(scanf("%d %d %c", &x, &y, &a)==3) { gets(command); lost = false; switch(a) { case 'N': dir = NORTH; break; case 'E': dir = EAST; break; case 'S': dir = SOUTH; break; case 'W': dir = WEST; break; } for(i=0, gets(command); command[i] && !lost; i++) { switch(command[i]) { case 'L': /* turn left */ dir = dir - 1; if(dir < 0) dir = 3; break; case 'R': dir = (dir+1) % 4; break; case 'F': a = x + move[dir][0]; b = y + move[dir][1]; if(a>=0 && a<=up_bound && b>=0 && b<=right_bound) /*如果不會掉下去就走*/ { x = a; y = b; } else if(!map[x][y]) /* 會掉下去 沒有記錄 就記錄 */ { map[x][y] = true; lost = true; } /*else*/ /* 會掉下去 有紀錄 不幹 */ break; } } printf("%d %d ", x, y); switch(dir) { case NORTH: putchar('N'); break; case EAST: putchar('E'); break; case SOUTH: putchar('S'); break; case WEST: putchar('W'); break; } printf("%s\n", lost?" LOST":""); } }
[ "yingshiuan.pan@gmail.com" ]
yingshiuan.pan@gmail.com
1f0b7f7d7cf44c89bfa2c79b3d391bfb2922ddff
295d1036365e1bc9625c68b633808daec19d9a72
/Section_4/Sample/src/main.cpp
c4b79d021ca185ed800a3ac1e8f82c502dd03e8d
[]
no_license
Cancain/udemy_CPP
e99a61cf9a52799670584c158623c166fb83110b
eff944ce3810c106e4367f50075d310e08cce56b
refs/heads/master
2020-12-05T10:12:06.354011
2020-06-30T18:17:20
2020-06-30T18:17:20
232,076,904
0
0
null
null
null
null
UTF-8
C++
false
false
92
cpp
#include <iostream> int main(){ std::cout << "Hello World"<< std::endl; return 0; }
[ "eriksson.tomas@gmail.com" ]
eriksson.tomas@gmail.com
bf44843a478accaa233b2ef33c38a15ca2b383e0
a8cfc37654d98793bb6c9f8ed4ff1b750791d4d8
/sofa-pbrpc/perf/client_continuous.cc
0fbb7ef555dfdf84dd0032c0003b4e452d5e4ee1
[]
no_license
qinzuoyan/sample
28ae78492fee7b6da0fb3a5bec8b02387e657c2a
fda2217e6284bfe1b8fec7c9f232ddf1843a3f36
refs/heads/master
2021-01-01T20:10:37.708010
2015-04-21T13:01:26
2015-04-21T13:01:26
33,721,235
0
1
null
null
null
null
UTF-8
C++
false
false
4,941
cc
#include <stdio.h> #include <signal.h> #include <unistd.h> #include <toft/system/atomic/atomic.h> #include <toft/system/time/clock.h> #include <toft/system/threading/this_thread.h> #include <sofa/pbrpc/rpc_client.h> #include <sofa/pbrpc/rpc_channel.h> #include <sofa/pbrpc/rpc_controller.h> #include <sofa/pbrpc/rpc_error_code.h> #include <sofa/pbrpc/closure.h> #include <sample/sofa-pbrpc/perf/echo_service.pb.h> static volatile bool s_is_running = true; static volatile bool s_should_wait = false; static toft::Atomic<int> s_print_token(0); static toft::Atomic<int> s_succeed_count(0); static toft::Atomic<int> s_timeout_count(0); static toft::Atomic<int> s_pending_full_count(0); static toft::Atomic<int> s_pending_count(0); void sigcatcher(int sig) { LOG(INFO) << "signal catched: " << sig; s_is_running = false; } void EchoCallback( sofa::pbrpc::RpcController* cntl, const sofa::pbrpc::test::EchoRequest* request, sofa::pbrpc::test::EchoResponse* response) { --s_pending_count; if (cntl->Failed()) { if (cntl->ErrorCode() == sofa::pbrpc::RPC_ERROR_SEND_BUFFER_FULL) { s_should_wait = true; ++s_pending_full_count; } else if (cntl->ErrorCode() == sofa::pbrpc::RPC_ERROR_REQUEST_TIMEOUT) { s_should_wait = true; ++s_timeout_count; } else { s_is_running = false; if (++s_print_token == 1) { LOG(ERROR) << "request failed: " << cntl->ErrorText(); } } } else if (request->message().size() != response->message().size()) { s_is_running = false; if (++s_print_token == 1) { LOG(ERROR) << "response not matched"; } } else { ++s_succeed_count; } delete response; delete cntl; } int main(int argc, char **argv) { // check command line arguments. if (argc < 4) { fprintf(stderr, "Usage: %s <host> <port> <message_size> [is_grace_exit]\n", argv[0]); return EXIT_FAILURE; } std::string address = argv[1] + std::string(":") + argv[2]; int message_size = atoi(argv[3]); std::string message_str; message_str.resize(message_size, 'z'); bool is_grace_exit = true; if (argc > 4) { if (strcmp(argv[4], "true") == 0) is_grace_exit = true; else if (strcmp(argv[4], "false") == 0) is_grace_exit = false; else { fprintf(stderr, "Invalid param 'is_grace_exit': should be 'true' or 'false'"); return EXIT_FAILURE; } } signal(SIGINT, &sigcatcher); signal(SIGTERM, &sigcatcher); // Define an rpc client. sofa::pbrpc::RpcClientOptions client_options; sofa::pbrpc::RpcClient rpc_client(client_options); // Define an rpc channel and stub. sofa::pbrpc::RpcChannelOptions channel_options; sofa::pbrpc::RpcChannel rpc_channel(&rpc_client, address, channel_options); sofa::pbrpc::test::EchoServer_Stub stub(&rpc_channel); sofa::pbrpc::test::EchoRequest echo_request; echo_request.set_message(message_str); int64_t print_interval_ms = 1000; int64_t last_time = toft::RealtimeClock.MilliSeconds(); long last_succeed_count = 0; while (s_is_running) { sofa::pbrpc::RpcController* cntl = new sofa::pbrpc::RpcController(); const sofa::pbrpc::test::EchoRequest* request = &echo_request; sofa::pbrpc::test::EchoResponse* response = new sofa::pbrpc::test::EchoResponse(); google::protobuf::Closure* done = sofa::pbrpc::NewClosure( &EchoCallback, cntl, request, response); ++s_pending_count; stub.Echo(cntl, request, response, done); if (s_should_wait || s_pending_count > 300000) { s_should_wait = false; usleep(100000); } int64_t now = toft::RealtimeClock.MilliSeconds(); if (now - last_time >= print_interval_ms) { long curr_succeed_count = s_succeed_count; LOG(INFO) << "QPS=" << (curr_succeed_count - last_succeed_count) << ", pending_count=" << static_cast<long>(s_pending_count) << ", timeout_count=" << static_cast<long>(s_timeout_count) << ", pending_full_count=" << static_cast<long>(s_pending_full_count); last_succeed_count = curr_succeed_count; last_time = now; } } if (is_grace_exit) { LOG(INFO) << "gracely exiting ..."; while (s_pending_count > 0) { LOG(INFO) << "pending count: " << static_cast<long>(s_pending_count); toft::ThisThread::Sleep(1000); } } rpc_client.Shutdown(); // should call Shutdown here! fprintf(stderr, "Succeed %ld\n", static_cast<long>(s_succeed_count)); return EXIT_SUCCESS; } /* vim: set ts=4 sw=4 sts=4 tw=100 */
[ "qinzuoyan@gmail.com" ]
qinzuoyan@gmail.com
93e8bdf17c6cdf537cfdd48b255e3b6d0c76497a
e62436e57c4b7db368cb47b3434ff342a39e6a85
/Kattis/bees.cpp
e93151097274bdb7eb7df3ca9ae0c8b1b2528de2
[]
no_license
JuanDiazDev/Solutions
7bcec667336a73ff6a6926e03490bf73a5f400bd
6f5224b2d1cefd5f1ed7544e686b07cd46fe7d09
refs/heads/main
2023-07-11T19:49:32.651746
2021-08-17T05:24:59
2021-08-17T05:24:59
304,709,039
0
0
null
null
null
null
UTF-8
C++
false
false
818
cpp
#include<iostream> #include<cmath> using namespace std; void bees(float d, int s){ if(d == 0 && s == 0) return; float arr[s][2]; short int array[s]; float input; for(int i=0;i<s;i++) array[i] = 0; for(int i=0;i<s;i++){ for(int j=0;j<2;j++){ cin >> input; arr[i][j] = input; } } for(int i=0;i<s;i++){ for(int j=i+1;j<s;j++){ if((sqrt(pow(arr[i][0]-arr[j][0], 2)+pow(arr[i][1]-arr[j][1], 2))) <= d){ array[i]=1; array[j]=1; } } } int sweet = 0; int sour = 0; for(short int i: array){ if(i == 1){ sour++; }else sweet++; } string a = to_string(sweet); string b = to_string(sour); cout << b + " sour, " + a + " sweet" << "\n"; } int main(){ float d; int s; while(cin >> d >> s){ bees(d, s); } return 0; }
[ "noreply@github.com" ]
noreply@github.com
dfd4d2a4c3275b1edcfc27bf2c8cb7d53d282cf9
3471d77b185b2cbc9f7717388aeb7c42bfb43126
/libc/misc/mntent.cc
dc326f45fd74c53e04310c76780fb0da697f9ee9
[ "BSD-3-Clause" ]
permissive
vladzcloudius/osv
fbcfcd016aa6625aa817a7466b3df1865d571781
d511e6c091b6de11aa3bb6b16a4c41dbbe2e56fc
refs/heads/master
2021-01-10T21:18:54.769543
2014-06-23T12:28:31
2014-06-25T07:25:08
17,629,484
1
0
null
null
null
null
UTF-8
C++
false
false
2,715
cc
#include <stdio.h> #include <string.h> #include <mntent.h> #include <errno.h> #include <osv/mount.h> FILE *setmntent(const char *name, const char *mode) { if (!strcmp(name, "/proc/mounts") || !strcmp(name, "/etc/mnttab") || !strcmp(name, "/etc/mtab")) { if (strcmp("r", mode)) { return nullptr; } return OSV_DYNMOUNTS; } return fopen(name, mode); } int endmntent(FILE *f) { if (f != OSV_DYNMOUNTS) { fclose(f); } return 1; } bool osv_getmntent(char *linebuf, int buflen) { // FIXME: we're using a static here in lieu of the file offset static size_t last = 0; auto mounts = osv::current_mounts(); if (last >= mounts.size()) { last = 0; return false; } else { auto& m = mounts[last++]; snprintf(linebuf, buflen, " %s %s %s %s 0 0", m.special.c_str(), m.path.c_str(), m.type.c_str(), m.options.size() ? m.options.c_str() : MNTOPT_DEFAULTS); return true; } } struct mntent *getmntent_r(FILE *f, struct mntent *mnt, char *linebuf, int buflen) { int cnt, n[8]; if (!f) { return nullptr; } mnt->mnt_freq = 0; mnt->mnt_passno = 0; do { if (f == OSV_DYNMOUNTS) { bool ret = osv_getmntent(linebuf, buflen); if (!ret) { return nullptr; } } else { fgets(linebuf, buflen, f); if (feof(f) || ferror(f)) return 0; if (!strchr(linebuf, '\n')) { fscanf(f, "%*[^\n]%*[\n]"); return nullptr; } } cnt = sscanf(linebuf, " %n%*s%n %n%*s%n %n%*s%n %n%*s%n %d %d", n, n+1, n+2, n+3, n+4, n+5, n+6, n+7, &mnt->mnt_freq, &mnt->mnt_passno); } while (cnt < 2 || linebuf[n[0]] == '#'); linebuf[n[1]] = 0; linebuf[n[3]] = 0; linebuf[n[5]] = 0; linebuf[n[7]] = 0; mnt->mnt_fsname = linebuf+n[0]; mnt->mnt_dir = linebuf+n[2]; mnt->mnt_type = linebuf+n[4]; mnt->mnt_opts = linebuf+n[6]; return mnt; } struct mntent *getmntent(FILE *f) { static char linebuf[256]; static struct mntent mnt; return getmntent_r(f, &mnt, linebuf, sizeof linebuf); } int addmntent(FILE *f, const struct mntent *mnt) { if (f == OSV_DYNMOUNTS) { return 1; } if (fseek(f, 0, SEEK_END)) return 1; return fprintf(f, "%s\t%s\t%s\t%s\t%d\t%d\n", mnt->mnt_fsname, mnt->mnt_dir, mnt->mnt_type, mnt->mnt_opts, mnt->mnt_freq, mnt->mnt_passno) < 0; } char *hasmntopt(const struct mntent *mnt, const char *opt) { return strstr(mnt->mnt_opts, opt); }
[ "penberg@cloudius-systems.com" ]
penberg@cloudius-systems.com
ce4b6609196857c02e78c7e23d5c5f665759e74a
3487f249665f096de6c42eda99bc3da3398bb547
/old/gfg/print-this-pattern.cpp
9e2ac0daf37bb4a7433af1b817c183351ceb4a1a
[]
no_license
hthuwal/competitive-programming
74489181774b4746234a62fe217ac539b2e1704e
65efdd8b90afd3895f734e204b9a4689de3eb810
refs/heads/master
2023-08-31T04:18:37.525826
2023-08-30T20:28:10
2023-08-30T20:28:10
133,988,036
5
2
null
2020-10-15T17:58:15
2018-05-18T18:02:05
C++
UTF-8
C++
false
false
749
cpp
/* https://practice.geeksforgeeks.org/problems/print-this-pattern/0 */ // Why is pattern printing cumbersome #include<bits/stdc++.h> using namespace std; void print(int i, int n) { for(int j=0;j<n;j++) printf("%d", i); } int main() { int t,n; for(scanf("%d", &t); t--;) { scanf("%d", &n); for(int i=0;i<n;i++) { int j,count = 0; for(j=n;j>=n-i;j--) { count++; print(j, 1); } j++; print(j, 2*(n-count)); for(j=j+1;j<=n;j++) { print(j,1); } printf("\n"); } for(int i=n-2;i>=0;i--) { int j,count = 0; for(j=n;j>=n-i;j--) { count++; print(j, 1); } j++; print(j, 2*(n-count)); for(j=j+1;j<=n;j++) { print(j,1); } printf("\n"); } } return 0; }
[ "hthuwal@gmail.com" ]
hthuwal@gmail.com
ccd91a382c6ba433605b3bd3588cc9d42d73bf93
2dc7c04bf11ff5206d9aafc1c22aa657a1d0c72e
/MidiNoteTeensy/MidiNoteTeensy.ino
50732440c2320e20e7317bd13c00282a4cefc3d6
[]
no_license
libbyodai7/SoundplayTeensyCode
4ed323593c25ba5af6faee27b775a0c90e49be10
1438036c8425672893d6ff36f17de33aa8677478
refs/heads/main
2023-07-09T10:15:00.182568
2021-08-20T15:57:22
2021-08-20T15:57:22
398,262,664
0
0
null
null
null
null
UTF-8
C++
false
false
918
ino
#include <HCSR04.h> const int channel = 3; // change channel valure here float data; float minimumDistance = 2.0; //change minimum distance here (cm) float maximumDistance = 70.0; //change maximum distance here (cm) byte current_value; byte previous_value; const int controller = 24; // change controlller value here UltraSonicDistanceSensor distanceSensor(0, 1); void setup () { } void loop () { usbMIDI.read(); data = distanceSensor.measureDistanceCm(); Serial.println(data); if (data >= minimumDistance && data <= maximimDistance) { current_value = map(data, minimumDistance, maximimDistance, 30, 85); Serial.println(current_value); if (current_value != previous_value) { usbMIDI.sendNoteOn( current_value, 100, channel); delay(100); usbMIDI.sendNoteOff( current_value, 100, channel); while (usbMIDI.read()) { } } delay(5); } }
[ "lydiaodai7@gmail.com" ]
lydiaodai7@gmail.com
cd0870590325d8948b7f2727275b40d24cbb8555
ea96b94077ca4dee5a15035e91f7a391a77de288
/src/main/ConstantSpeed.ino
8421e4f1b77e0982548be7b29e3f1b94d364ac06
[]
no_license
raejeong/GittyFirmware
2ebede81ecba4f1951520388ef5b4625baadf2a2
c6ab4b15875cbcfcb3a535fee09fbb05d18ad6aa
refs/heads/master
2020-12-03T02:11:17.656097
2017-08-09T23:03:17
2017-08-09T23:03:17
95,914,359
0
0
null
null
null
null
UTF-8
C++
false
false
1,538
ino
// ConstantSpeed.pde // -*- mode: C++ -*- // // Shows how to run AccelStepper in the simplest, // fixed speed mode with no accelerations // Requires the Adafruit_Motorshield v2 library // https://github.com/adafruit/Adafruit_Motor_Shield_V2_Library // And AccelStepper with AFMotor support // https://github.com/adafruit/AccelStepper // This tutorial is for Adafruit Motorshield v2 only! // Will not work with v1 shields #include "AccelStepper.h" #include "Adafruit_MotorShield.h" #include "Adafruit_MS_PWMServoDriver.h" // Create the motor shield object with the default I2C address Adafruit_MotorShield AFMS = Adafruit_MotorShield(); // Or, create it with a different I2C address (say for stacking) // Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61); // Connect a stepper motor with 200 steps per revolution (1.8 degree) // to motor port #2 (M3 and M4) Adafruit_StepperMotor *myStepper1 = AFMS.getStepper(200, 2); // you can change these to DOUBLE or INTERLEAVE or MICROSTEP! void forwardstep1() { myStepper1->onestep(FORWARD, DOUBLE); } void backwardstep1() { myStepper1->onestep(BACKWARD, DOUBLE); } AccelStepper Astepper1(forwardstep1, backwardstep1); // use functions to step void setup() { Serial.begin(9600); // set up Serial library at 9600 bps Serial.println("Stepper test!"); AFMS.begin(); // create with the default frequency 1.6KHz //AFMS.begin(1000); // OR with a different frequency, say 1KHz Astepper1.setSpeed(50); } void loop() { Astepper1.runSpeed(); }
[ "rae.jeong@istuary.com" ]
rae.jeong@istuary.com
920825dbff3f7b4d987ecb1f95b390dd9d31e4f2
162a3db1eb6017a94e9f378d7a20f61e581ecbe9
/src/chrome/browser/renderer_context_menu/render_view_context_menu.cc
b4340568017d9750a19a40e91743578b4b3b77c8
[ "BSD-3-Clause" ]
permissive
webosose/chromium84
705fbac37c5cfecd36113b41b7a0f4e8adf249d5
5decc42bef727dc957683fb5d8fa2fcc78936f15
refs/heads/master
2023-05-29T13:53:50.190538
2021-06-08T07:56:29
2021-06-10T01:19:24
330,895,427
0
2
null
null
null
null
UTF-8
C++
false
false
119,736
cc
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" #include <stddef.h> #include <algorithm> #include <set> #include <utility> #include "base/bind.h" #include "base/command_line.h" #include "base/feature_list.h" #include "base/logging.h" #include "base/metrics/field_trial.h" #include "base/metrics/histogram_macros.h" #include "base/metrics/user_metrics.h" #include "base/no_destructor.h" #include "base/stl_util.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" #include "build/branding_buildflags.h" #include "build/build_config.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/app/vector_icons/vector_icons.h" #include "chrome/browser/app_mode/app_mode_utils.h" #include "chrome/browser/apps/app_service/app_launch_params.h" #include "chrome/browser/apps/app_service/app_service_proxy.h" #include "chrome/browser/apps/app_service/app_service_proxy_factory.h" #include "chrome/browser/apps/app_service/browser_app_launcher.h" #include "chrome/browser/apps/platform_apps/app_load_service.h" #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" #include "chrome/browser/data_reduction_proxy/data_reduction_proxy_chrome_settings.h" #include "chrome/browser/data_reduction_proxy/data_reduction_proxy_chrome_settings_factory.h" #include "chrome/browser/devtools/devtools_window.h" #include "chrome/browser/download/download_stats.h" #include "chrome/browser/language/language_model_manager_factory.h" #include "chrome/browser/media/router/media_router_dialog_controller.h" #include "chrome/browser/media/router/media_router_feature.h" #include "chrome/browser/media/router/media_router_metrics.h" #include "chrome/browser/password_manager/chrome_password_manager_client.h" #include "chrome/browser/platform_util.h" #include "chrome/browser/prefs/incognito_mode_prefs.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_attributes_entry.h" #include "chrome/browser/profiles/profile_attributes_storage.h" #include "chrome/browser/profiles/profile_avatar_icon_util.h" #include "chrome/browser/profiles/profile_io_data.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_window.h" #include "chrome/browser/renderer_context_menu/accessibility_labels_menu_observer.h" #include "chrome/browser/renderer_context_menu/context_menu_content_type_factory.h" #include "chrome/browser/renderer_context_menu/spelling_menu_observer.h" #include "chrome/browser/search/search.h" #include "chrome/browser/search_engines/template_url_service_factory.h" #include "chrome/browser/send_tab_to_self/send_tab_to_self_desktop_util.h" #include "chrome/browser/send_tab_to_self/send_tab_to_self_util.h" #include "chrome/browser/sharing/click_to_call/click_to_call_context_menu_observer.h" #include "chrome/browser/sharing/click_to_call/click_to_call_metrics.h" #include "chrome/browser/sharing/click_to_call/click_to_call_utils.h" #include "chrome/browser/sharing/shared_clipboard/shared_clipboard_context_menu_observer.h" #include "chrome/browser/sharing/shared_clipboard/shared_clipboard_utils.h" #include "chrome/browser/spellchecker/spellcheck_service.h" #include "chrome/browser/translate/chrome_translate_client.h" #include "chrome/browser/translate/translate_service.h" #include "chrome/browser/ui/autofill/chrome_autofill_client.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_navigator_params.h" #include "chrome/browser/ui/chrome_pages.h" #include "chrome/browser/ui/exclusive_access/keyboard_lock_controller.h" #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" #include "chrome/browser/ui/qrcode_generator/qrcode_generator_bubble_controller.h" #include "chrome/browser/ui/tab_contents/core_tab_helper.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/webui/history/foreign_session_handler.h" #include "chrome/browser/web_applications/components/app_registrar.h" #include "chrome/browser/web_applications/components/web_app_helpers.h" #include "chrome/browser/web_applications/components/web_app_provider_base.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_features.h" #include "chrome/common/chrome_render_frame.mojom.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/content_restriction.h" #include "chrome/common/pref_names.h" #include "chrome/common/render_messages.h" #include "chrome/common/url_constants.h" #include "chrome/common/webui_url_constants.h" #include "chrome/grit/chromium_strings.h" #include "chrome/grit/generated_resources.h" #include "components/arc/arc_features.h" #include "components/autofill/core/browser/ui/popup_item_ids.h" #include "components/autofill/core/common/password_generation_util.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h" #include "components/download/public/common/download_url_parameters.h" #include "components/google/core/common/google_util.h" #include "components/guest_view/browser/guest_view_base.h" #include "components/language/core/browser/language_model_manager.h" #include "components/omnibox/browser/autocomplete_classifier.h" #include "components/omnibox/browser/autocomplete_match.h" #include "components/password_manager/content/browser/content_password_manager_driver.h" #include "components/password_manager/core/browser/password_manager_metrics_util.h" #include "components/password_manager/core/browser/password_manager_util.h" #include "components/prefs/pref_member.h" #include "components/prefs/pref_service.h" #include "components/search_engines/template_url.h" #include "components/search_engines/template_url_service.h" #include "components/spellcheck/browser/pref_names.h" #include "components/spellcheck/browser/spellcheck_host_metrics.h" #include "components/spellcheck/common/spellcheck_common.h" #include "components/spellcheck/spellcheck_buildflags.h" #include "components/strings/grit/components_strings.h" #include "components/translate/core/browser/translate_download_manager.h" #include "components/translate/core/browser/translate_manager.h" #include "components/translate/core/browser/translate_prefs.h" #include "components/url_formatter/url_formatter.h" #include "components/user_prefs/user_prefs.h" #include "components/web_modal/web_contents_modal_dialog_manager.h" #include "content/public/browser/child_process_security_policy.h" #include "content/public/browser/download_manager.h" #include "content/public/browser/navigation_details.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/picture_in_picture_window_controller.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/ssl_status.h" #include "content/public/browser/web_contents.h" #include "content/public/common/menu_item.h" #include "content/public/common/url_utils.h" #include "extensions/buildflags/buildflags.h" #include "media/base/media_switches.h" #include "mojo/public/cpp/bindings/associated_remote.h" #include "net/base/escape.h" #include "net/traffic_annotation/network_traffic_annotation.h" #include "ppapi/buildflags/buildflags.h" #include "printing/buildflags/buildflags.h" #include "services/service_manager/public/cpp/interface_provider.h" #include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" #include "third_party/blink/public/common/context_menu_data/edit_flags.h" #include "third_party/blink/public/common/context_menu_data/input_field_type.h" #include "third_party/blink/public/common/context_menu_data/media_type.h" #include "third_party/blink/public/mojom/frame/media_player_action.mojom.h" #include "third_party/blink/public/public_buildflags.h" #include "third_party/metrics_proto/omnibox_input_type.pb.h" #include "ui/base/clipboard/clipboard.h" #include "ui/base/clipboard/scoped_clipboard_writer.h" #include "ui/base/emoji/emoji_panel_helper.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/models/image_model.h" #include "ui/gfx/favicon_size.h" #include "ui/gfx/geometry/point.h" #include "ui/gfx/text_elider.h" #include "ui/strings/grit/ui_strings.h" #if BUILDFLAG(USE_RENDERER_SPELLCHECKER) #include "chrome/browser/renderer_context_menu/spelling_options_submenu_observer.h" #endif #if BUILDFLAG(ENABLE_EXTENSIONS) #include "chrome/browser/apps/app_service/app_launch_params.h" #include "chrome/browser/extensions/devtools_util.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/common/extensions/api/url_handlers/url_handlers_parser.h" #include "extensions/browser/extension_host.h" #include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_system.h" #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h" #include "extensions/browser/guest_view/web_view/web_view_guest.h" #include "extensions/browser/view_type_utils.h" #include "extensions/common/extension.h" #endif #if BUILDFLAG(ENABLE_PLUGINS) #include "chrome/browser/plugins/chrome_plugin_service_filter.h" #endif #if BUILDFLAG(ENABLE_PRINTING) #include "chrome/browser/printing/print_view_manager_common.h" #include "components/printing/common/print.mojom.h" #if BUILDFLAG(ENABLE_PRINT_PREVIEW) #include "chrome/browser/printing/print_preview_context_menu_observer.h" #include "chrome/browser/printing/print_preview_dialog_controller.h" #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) #endif // BUILDFLAG(ENABLE_PRINTING) #if BUILDFLAG(GOOGLE_CHROME_BRANDING) #include "chrome/grit/theme_resources.h" #include "ui/base/resource/resource_bundle.h" #endif #if defined(OS_CHROMEOS) #include "chrome/browser/chromeos/arc/arc_util.h" #include "chrome/browser/chromeos/arc/intent_helper/open_with_menu.h" #include "chrome/browser/chromeos/arc/intent_helper/start_smart_selection_action_menu.h" #include "chrome/browser/renderer_context_menu/quick_answers_menu_observer.h" #endif using base::UserMetricsAction; using blink::ContextMenuDataEditFlags; using blink::ContextMenuDataMediaType; using blink::WebContextMenuData; using blink::WebString; using blink::WebURL; using content::BrowserContext; using content::ChildProcessSecurityPolicy; using content::DownloadManager; using content::NavigationEntry; using content::OpenURLParams; using content::RenderFrameHost; using content::RenderViewHost; using content::SSLStatus; using content::WebContents; using download::DownloadUrlParameters; using extensions::ContextMenuMatcher; using extensions::Extension; using extensions::MenuItem; using extensions::MenuManager; namespace { base::OnceCallback<void(RenderViewContextMenu*)>* GetMenuShownCallback() { static base::NoDestructor<base::OnceCallback<void(RenderViewContextMenu*)>> callback; return callback.get(); } // State of the profile that is activated via "Open Link as User". enum UmaEnumOpenLinkAsUser { OPEN_LINK_AS_USER_ACTIVE_PROFILE_ENUM_ID, OPEN_LINK_AS_USER_INACTIVE_PROFILE_MULTI_PROFILE_SESSION_ENUM_ID, OPEN_LINK_AS_USER_INACTIVE_PROFILE_SINGLE_PROFILE_SESSION_ENUM_ID, OPEN_LINK_AS_USER_LAST_ENUM_ID, }; // State of other profiles when the "Open Link as User" context menu is shown. enum UmaEnumOpenLinkAsUserProfilesState { OPEN_LINK_AS_USER_PROFILES_STATE_NO_OTHER_ACTIVE_PROFILES_ENUM_ID, OPEN_LINK_AS_USER_PROFILES_STATE_OTHER_ACTIVE_PROFILES_ENUM_ID, OPEN_LINK_AS_USER_PROFILES_STATE_LAST_ENUM_ID, }; #if !defined(OS_CHROMEOS) // We report the number of "Open Link as User" entries shown in the context // menu via UMA, differentiating between at most that many profiles. const int kOpenLinkAsUserMaxProfilesReported = 10; #endif // !defined(OS_CHROMEOS) enum class UmaEnumIdLookupType { GeneralEnumId, ContextSpecificEnumId, }; const std::map<int, int>& GetIdcToUmaMap(UmaEnumIdLookupType type) { // These maps are from IDC_* -> UMA value. Never alter UMA ids. You may remove // items, but add a line to keep the old value from being reused. // These UMA values are for the the RenderViewContextMenuItem enum, used for // the RenderViewContextMenu.Shown and RenderViewContextMenu.Used histograms. static base::NoDestructor<std::map<int, int>> general_map( {// NB: UMA values for 0 and 1 are detected using // RenderViewContextMenu::IsContentCustomCommandId() and // ContextMenuMatcher::IsExtensionsCustomCommandId() {IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST, 2}, {IDC_CONTENT_CONTEXT_OPENLINKNEWTAB, 3}, {IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW, 4}, {IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD, 5}, {IDC_CONTENT_CONTEXT_SAVELINKAS, 6}, {IDC_CONTENT_CONTEXT_SAVEAVAS, 7}, {IDC_CONTENT_CONTEXT_SAVEIMAGEAS, 8}, {IDC_CONTENT_CONTEXT_COPYLINKLOCATION, 9}, {IDC_CONTENT_CONTEXT_COPYIMAGELOCATION, 10}, {IDC_CONTENT_CONTEXT_COPYAVLOCATION, 11}, {IDC_CONTENT_CONTEXT_COPYIMAGE, 12}, {IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB, 13}, {IDC_CONTENT_CONTEXT_OPENAVNEWTAB, 14}, {IDC_CONTENT_CONTEXT_PLAYPAUSE, 15}, {IDC_CONTENT_CONTEXT_MUTE, 16}, {IDC_CONTENT_CONTEXT_LOOP, 17}, {IDC_CONTENT_CONTEXT_CONTROLS, 18}, {IDC_CONTENT_CONTEXT_ROTATECW, 19}, {IDC_CONTENT_CONTEXT_ROTATECCW, 20}, {IDC_BACK, 21}, {IDC_FORWARD, 22}, {IDC_SAVE_PAGE, 23}, {IDC_RELOAD, 24}, {IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP, 25}, {IDC_CONTENT_CONTEXT_RESTART_PACKAGED_APP, 26}, {IDC_PRINT, 27}, {IDC_VIEW_SOURCE, 28}, {IDC_CONTENT_CONTEXT_INSPECTELEMENT, 29}, {IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE, 30}, {IDC_CONTENT_CONTEXT_VIEWPAGEINFO, 31}, {IDC_CONTENT_CONTEXT_TRANSLATE, 32}, {IDC_CONTENT_CONTEXT_RELOADFRAME, 33}, {IDC_CONTENT_CONTEXT_VIEWFRAMESOURCE, 34}, {IDC_CONTENT_CONTEXT_VIEWFRAMEINFO, 35}, {IDC_CONTENT_CONTEXT_UNDO, 36}, {IDC_CONTENT_CONTEXT_REDO, 37}, {IDC_CONTENT_CONTEXT_CUT, 38}, {IDC_CONTENT_CONTEXT_COPY, 39}, {IDC_CONTENT_CONTEXT_PASTE, 40}, {IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE, 41}, {IDC_CONTENT_CONTEXT_DELETE, 42}, {IDC_CONTENT_CONTEXT_SELECTALL, 43}, {IDC_CONTENT_CONTEXT_SEARCHWEBFOR, 44}, {IDC_CONTENT_CONTEXT_GOTOURL, 45}, {IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS, 46}, {IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS, 47}, {IDC_CONTENT_CONTEXT_OPENLINKWITH, 52}, {IDC_CHECK_SPELLING_WHILE_TYPING, 53}, {IDC_SPELLCHECK_MENU, 54}, {IDC_CONTENT_CONTEXT_SPELLING_TOGGLE, 55}, {IDC_SPELLCHECK_LANGUAGES_FIRST, 56}, {IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE, 57}, {IDC_SPELLCHECK_SUGGESTION_0, 58}, {IDC_SPELLCHECK_ADD_TO_DICTIONARY, 59}, {IDC_SPELLPANEL_TOGGLE, 60}, {IDC_CONTENT_CONTEXT_OPEN_ORIGINAL_IMAGE_NEW_TAB, 61}, {IDC_WRITING_DIRECTION_MENU, 62}, {IDC_WRITING_DIRECTION_DEFAULT, 63}, {IDC_WRITING_DIRECTION_LTR, 64}, {IDC_WRITING_DIRECTION_RTL, 65}, {IDC_CONTENT_CONTEXT_LOAD_IMAGE, 66}, {IDC_ROUTE_MEDIA, 68}, {IDC_CONTENT_CONTEXT_COPYLINKTEXT, 69}, {IDC_CONTENT_CONTEXT_OPENLINKINPROFILE, 70}, {IDC_OPEN_LINK_IN_PROFILE_FIRST, 71}, {IDC_CONTENT_CONTEXT_GENERATEPASSWORD, 72}, {IDC_SPELLCHECK_MULTI_LINGUAL, 73}, {IDC_CONTENT_CONTEXT_OPEN_WITH1, 74}, {IDC_CONTENT_CONTEXT_OPEN_WITH2, 75}, {IDC_CONTENT_CONTEXT_OPEN_WITH3, 76}, {IDC_CONTENT_CONTEXT_OPEN_WITH4, 77}, {IDC_CONTENT_CONTEXT_OPEN_WITH5, 78}, {IDC_CONTENT_CONTEXT_OPEN_WITH6, 79}, {IDC_CONTENT_CONTEXT_OPEN_WITH7, 80}, {IDC_CONTENT_CONTEXT_OPEN_WITH8, 81}, {IDC_CONTENT_CONTEXT_OPEN_WITH9, 82}, {IDC_CONTENT_CONTEXT_OPEN_WITH10, 83}, {IDC_CONTENT_CONTEXT_OPEN_WITH11, 84}, {IDC_CONTENT_CONTEXT_OPEN_WITH12, 85}, {IDC_CONTENT_CONTEXT_OPEN_WITH13, 86}, {IDC_CONTENT_CONTEXT_OPEN_WITH14, 87}, {IDC_CONTENT_CONTEXT_EXIT_FULLSCREEN, 88}, {IDC_CONTENT_CONTEXT_OPENLINKBOOKMARKAPP, 89}, {IDC_CONTENT_CONTEXT_SHOWALLSAVEDPASSWORDS, 90}, {IDC_CONTENT_CONTEXT_PICTUREINPICTURE, 91}, {IDC_CONTENT_CONTEXT_EMOJI, 92}, {IDC_CONTENT_CONTEXT_START_SMART_SELECTION_ACTION1, 93}, {IDC_CONTENT_CONTEXT_START_SMART_SELECTION_ACTION2, 94}, {IDC_CONTENT_CONTEXT_START_SMART_SELECTION_ACTION3, 95}, {IDC_CONTENT_CONTEXT_START_SMART_SELECTION_ACTION4, 96}, {IDC_CONTENT_CONTEXT_START_SMART_SELECTION_ACTION5, 97}, {IDC_CONTENT_CONTEXT_LOOK_UP, 98}, {IDC_CONTENT_CONTEXT_ACCESSIBILITY_LABELS_TOGGLE, 99}, {IDC_CONTENT_CONTEXT_ACCESSIBILITY_LABELS_TOGGLE_ONCE, 100}, {IDC_CONTENT_CONTEXT_ACCESSIBILITY_LABELS, 101}, {IDC_SEND_TAB_TO_SELF, 102}, {IDC_CONTENT_LINK_SEND_TAB_TO_SELF, 103}, {IDC_SEND_TAB_TO_SELF_SINGLE_TARGET, 104}, {IDC_CONTENT_LINK_SEND_TAB_TO_SELF_SINGLE_TARGET, 105}, {IDC_CONTENT_CONTEXT_SHARING_CLICK_TO_CALL_SINGLE_DEVICE, 106}, {IDC_CONTENT_CONTEXT_SHARING_CLICK_TO_CALL_MULTIPLE_DEVICES, 107}, {IDC_CONTENT_CONTEXT_SHARING_SHARED_CLIPBOARD_SINGLE_DEVICE, 108}, {IDC_CONTENT_CONTEXT_SHARING_SHARED_CLIPBOARD_MULTIPLE_DEVICES, 109}, {IDC_CONTENT_CONTEXT_GENERATE_QR_CODE, 110}, // To add new items: // - Add one more line above this comment block, using the UMA value // from the line below this comment block. // - Increment the UMA value in that latter line. // - Add the new item to the RenderViewContextMenuItem enum in // tools/metrics/histograms/enums.xml. {0, 111}}); // These UMA values are for the the ContextMenuOptionDesktop enum, used for // the ContextMenu.SelectedOptionDesktop histograms. static base::NoDestructor<std::map<int, int>> specific_map( {{IDC_CONTENT_CONTEXT_OPENLINKNEWTAB, 0}, {IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD, 1}, {IDC_CONTENT_CONTEXT_COPYLINKLOCATION, 2}, {IDC_CONTENT_CONTEXT_COPY, 3}, {IDC_CONTENT_CONTEXT_SAVELINKAS, 4}, {IDC_CONTENT_CONTEXT_SAVEIMAGEAS, 5}, {IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB, 6}, {IDC_CONTENT_CONTEXT_COPYIMAGE, 7}, {IDC_CONTENT_CONTEXT_COPYIMAGELOCATION, 8}, {IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE, 9}, {IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW, 10}, {IDC_PRINT, 11}, {IDC_CONTENT_CONTEXT_SEARCHWEBFOR, 12}, {IDC_CONTENT_CONTEXT_SAVEAVAS, 13}, {IDC_SPELLCHECK_SUGGESTION_0, 14}, {IDC_SPELLCHECK_ADD_TO_DICTIONARY, 15}, {IDC_CONTENT_CONTEXT_SPELLING_TOGGLE, 16}, {IDC_CONTENT_CONTEXT_CUT, 17}, {IDC_CONTENT_CONTEXT_PASTE, 18}, {IDC_CONTENT_CONTEXT_GOTOURL, 19}, // To add new items: // - Add one more line above this comment block, using the UMA value // from the line below this comment block. // - Increment the UMA value in that latter line. // - Add the new item to the ContextMenuOptionDesktop enum in // tools/metrics/histograms/enums.xml. {0, 20}}); return *(type == UmaEnumIdLookupType::GeneralEnumId ? general_map : specific_map); } int GetUmaValueMax(UmaEnumIdLookupType type) { // The IDC_ "value" of 0 is really a sentinel for the UMA max value. return GetIdcToUmaMap(type).find(0)->second; } // Collapses large ranges of ids before looking for UMA enum. int CollapseCommandsForUMA(int id) { DCHECK(!RenderViewContextMenu::IsContentCustomCommandId(id)); DCHECK(!ContextMenuMatcher::IsExtensionsCustomCommandId(id)); if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST && id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) { return IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST; } if (id >= IDC_SPELLCHECK_LANGUAGES_FIRST && id <= IDC_SPELLCHECK_LANGUAGES_LAST) { return IDC_SPELLCHECK_LANGUAGES_FIRST; } if (id >= IDC_SPELLCHECK_SUGGESTION_0 && id <= IDC_SPELLCHECK_SUGGESTION_LAST) { return IDC_SPELLCHECK_SUGGESTION_0; } if (id >= IDC_OPEN_LINK_IN_PROFILE_FIRST && id <= IDC_OPEN_LINK_IN_PROFILE_LAST) { return IDC_OPEN_LINK_IN_PROFILE_FIRST; } return id; } // Returns UMA enum value for command specified by |id| or -1 if not found. int FindUMAEnumValueForCommand(int id, UmaEnumIdLookupType type) { if (RenderViewContextMenu::IsContentCustomCommandId(id)) return 0; if (ContextMenuMatcher::IsExtensionsCustomCommandId(id)) return 1; id = CollapseCommandsForUMA(id); const auto& map = GetIdcToUmaMap(type); auto it = map.find(id); if (it == map.end()) return -1; return it->second; } // Returns true if the command id is for opening a link. bool IsCommandForOpenLink(int id) { return id == IDC_CONTENT_CONTEXT_OPENLINKNEWTAB || id == IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW || id == IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD || (id >= IDC_OPEN_LINK_IN_PROFILE_FIRST && id <= IDC_OPEN_LINK_IN_PROFILE_LAST); } // Returns the preference of the profile represented by the |context|. PrefService* GetPrefs(content::BrowserContext* context) { return user_prefs::UserPrefs::Get(context); } bool ExtensionPatternMatch(const extensions::URLPatternSet& patterns, const GURL& url) { // No patterns means no restriction, so that implicitly matches. if (patterns.is_empty()) return true; return patterns.MatchesURL(url); } const GURL& GetDocumentURL(const content::ContextMenuParams& params) { return params.frame_url.is_empty() ? params.page_url : params.frame_url; } content::Referrer CreateReferrer(const GURL& url, const content::ContextMenuParams& params) { const GURL& referring_url = GetDocumentURL(params); return content::Referrer::SanitizeForRequest( url, content::Referrer(referring_url.GetAsReferrer(), params.referrer_policy)); } content::WebContents* GetWebContentsToUse(content::WebContents* web_contents) { #if BUILDFLAG(ENABLE_EXTENSIONS) // If we're viewing in a MimeHandlerViewGuest, use its embedder WebContents. auto* guest_view = extensions::MimeHandlerViewGuest::FromWebContents(web_contents); if (guest_view) return guest_view->embedder_web_contents(); #endif return web_contents; } bool g_custom_id_ranges_initialized = false; #if !defined(OS_CHROMEOS) void AddAvatarToLastMenuItem(const gfx::Image& icon, ui::SimpleMenuModel* menu) { // Don't try to scale too small icons. if (icon.Width() < 16 || icon.Height() < 16) return; int target_dip_width = icon.Width(); int target_dip_height = icon.Height(); gfx::CalculateFaviconTargetSize(&target_dip_width, &target_dip_height); gfx::Image sized_icon = profiles::GetSizedAvatarIcon( icon, true /* is_rectangle */, target_dip_width, target_dip_height, profiles::SHAPE_CIRCLE); menu->SetIcon(menu->GetItemCount() - 1, ui::ImageModel::FromImage(sized_icon)); } #endif // !defined(OS_CHROMEOS) void OnProfileCreated(const GURL& link_url, const content::Referrer& referrer, Profile* profile, Profile::CreateStatus status) { if (status == Profile::CREATE_STATUS_INITIALIZED) { Browser* browser = chrome::FindLastActiveWithProfile(profile); NavigateParams nav_params( browser, link_url, /* |ui::PAGE_TRANSITION_TYPED| is used rather than |ui::PAGE_TRANSITION_LINK| since this ultimately opens the link in another browser. This parameter is used within the tab strip model of the browser it opens in implying a link from the active tab in the destination browser which is not correct. */ ui::PAGE_TRANSITION_TYPED); nav_params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; nav_params.referrer = referrer; nav_params.window_action = NavigateParams::SHOW_WINDOW; Navigate(&nav_params); } } bool DoesInputFieldTypeSupportEmoji( blink::ContextMenuDataInputFieldType text_input_type) { // Disable emoji for input types that definitely do not support emoji. switch (text_input_type) { case blink::ContextMenuDataInputFieldType::kNumber: case blink::ContextMenuDataInputFieldType::kTelephone: case blink::ContextMenuDataInputFieldType::kOther: return false; default: return true; } } } // namespace // static bool RenderViewContextMenu::IsDevToolsURL(const GURL& url) { return url.SchemeIs(content::kChromeDevToolsScheme); } // static void RenderViewContextMenu::AddSpellCheckServiceItem(ui::SimpleMenuModel* menu, bool is_checked) { if (is_checked) { menu->AddCheckItemWithStringId(IDC_CONTENT_CONTEXT_SPELLING_TOGGLE, IDS_CONTENT_CONTEXT_SPELLING_ASK_GOOGLE); } else { menu->AddItemWithStringId(IDC_CONTENT_CONTEXT_SPELLING_TOGGLE, IDS_CONTENT_CONTEXT_SPELLING_ASK_GOOGLE); } } RenderViewContextMenu::RenderViewContextMenu( content::RenderFrameHost* render_frame_host, const content::ContextMenuParams& params) : RenderViewContextMenuBase(render_frame_host, params), extension_items_(browser_context_, this, &menu_model_, base::Bind(MenuItemMatchesParams, params_)), profile_link_submenu_model_(this), multiple_profiles_open_(false), protocol_handler_submenu_model_(this), protocol_handler_registry_( ProtocolHandlerRegistryFactory::GetForBrowserContext(GetProfile())), accessibility_labels_submenu_model_(this), embedder_web_contents_(GetWebContentsToUse(source_web_contents_)) { if (!g_custom_id_ranges_initialized) { g_custom_id_ranges_initialized = true; SetContentCustomCommandIdRange(IDC_CONTENT_CONTEXT_CUSTOM_FIRST, IDC_CONTENT_CONTEXT_CUSTOM_LAST); } set_content_type(ContextMenuContentTypeFactory::Create( source_web_contents_, params)); } RenderViewContextMenu::~RenderViewContextMenu() { } // Menu construction functions ------------------------------------------------- #if BUILDFLAG(ENABLE_EXTENSIONS) // static bool RenderViewContextMenu::ExtensionContextAndPatternMatch( const content::ContextMenuParams& params, const MenuItem::ContextList& contexts, const extensions::URLPatternSet& target_url_patterns) { const bool has_link = !params.link_url.is_empty(); const bool has_selection = !params.selection_text.empty(); const bool in_frame = !params.frame_url.is_empty(); if (contexts.Contains(MenuItem::ALL) || (has_selection && contexts.Contains(MenuItem::SELECTION)) || (params.is_editable && contexts.Contains(MenuItem::EDITABLE)) || (in_frame && contexts.Contains(MenuItem::FRAME))) return true; if (has_link && contexts.Contains(MenuItem::LINK) && ExtensionPatternMatch(target_url_patterns, params.link_url)) return true; switch (params.media_type) { case ContextMenuDataMediaType::kImage: if (contexts.Contains(MenuItem::IMAGE) && ExtensionPatternMatch(target_url_patterns, params.src_url)) return true; break; case ContextMenuDataMediaType::kVideo: if (contexts.Contains(MenuItem::VIDEO) && ExtensionPatternMatch(target_url_patterns, params.src_url)) return true; break; case ContextMenuDataMediaType::kAudio: if (contexts.Contains(MenuItem::AUDIO) && ExtensionPatternMatch(target_url_patterns, params.src_url)) return true; break; default: break; } // PAGE is the least specific context, so we only examine that if none of the // other contexts apply (except for FRAME, which is included in PAGE for // backwards compatibility). if (!has_link && !has_selection && !params.is_editable && params.media_type == ContextMenuDataMediaType::kNone && contexts.Contains(MenuItem::PAGE)) return true; return false; } // static bool RenderViewContextMenu::MenuItemMatchesParams( const content::ContextMenuParams& params, const extensions::MenuItem* item) { bool match = ExtensionContextAndPatternMatch(params, item->contexts(), item->target_url_patterns()); if (!match) return false; const GURL& document_url = GetDocumentURL(params); return ExtensionPatternMatch(item->document_url_patterns(), document_url); } void RenderViewContextMenu::AppendAllExtensionItems() { extension_items_.Clear(); extensions::ExtensionRegistry* registry = extensions::ExtensionRegistry::Get(browser_context_); MenuManager* menu_manager = MenuManager::Get(browser_context_); if (!menu_manager) return; base::string16 printable_selection_text = PrintableSelectionText(); EscapeAmpersands(&printable_selection_text); // Get a list of extension id's that have context menu items, and sort by the // top level context menu title of the extension. std::set<MenuItem::ExtensionKey> ids = menu_manager->ExtensionIds(); std::vector<base::string16> sorted_menu_titles; std::map<base::string16, std::vector<const Extension*>> title_to_extensions_map; for (auto iter = ids.begin(); iter != ids.end(); ++iter) { const Extension* extension = registry->GetExtensionById( iter->extension_id, extensions::ExtensionRegistry::ENABLED); // Platform apps have their context menus created directly in // AppendPlatformAppItems. if (extension && !extension->is_platform_app()) { base::string16 menu_title = extension_items_.GetTopLevelContextMenuTitle( *iter, printable_selection_text); title_to_extensions_map[menu_title].push_back(extension); sorted_menu_titles.push_back(menu_title); } } if (sorted_menu_titles.empty()) return; const std::string app_locale = g_browser_process->GetApplicationLocale(); l10n_util::SortStrings16(app_locale, &sorted_menu_titles); sorted_menu_titles.erase( std::unique(sorted_menu_titles.begin(), sorted_menu_titles.end()), sorted_menu_titles.end()); int index = 0; for (const auto& title : sorted_menu_titles) { const std::vector<const Extension*>& extensions = title_to_extensions_map[title]; for (const Extension* extension : extensions) { MenuItem::ExtensionKey extension_key(extension->id()); extension_items_.AppendExtensionItems(extension_key, printable_selection_text, &index, /*is_action_menu=*/false); } } } void RenderViewContextMenu::AppendCurrentExtensionItems() { // Avoid appending extension related items when |extension| is null. // For Panel, this happens when the panel is navigated to a url outside of the // extension's package. const Extension* extension = GetExtension(); if (!extension) return; extensions::WebViewGuest* web_view_guest = extensions::WebViewGuest::FromWebContents(source_web_contents_); MenuItem::ExtensionKey key; if (web_view_guest) { key = MenuItem::ExtensionKey(extension->id(), web_view_guest->owner_web_contents() ->GetMainFrame() ->GetProcess() ->GetID(), web_view_guest->view_instance_id()); } else { key = MenuItem::ExtensionKey(extension->id()); } // Only add extension items from this extension. int index = 0; extension_items_.AppendExtensionItems(key, PrintableSelectionText(), &index, /*is_action_menu=*/false); } #endif // BUILDFLAG(ENABLE_EXTENSIONS) base::string16 RenderViewContextMenu::FormatURLForClipboard(const GURL& url) { DCHECK(!url.is_empty()); DCHECK(url.is_valid()); GURL url_to_format = url; url_formatter::FormatUrlTypes format_types; net::UnescapeRule::Type unescape_rules; if (url.SchemeIs(url::kMailToScheme)) { GURL::Replacements replacements; replacements.ClearQuery(); url_to_format = url.ReplaceComponents(replacements); format_types = url_formatter::kFormatUrlOmitMailToScheme; unescape_rules = net::UnescapeRule::PATH_SEPARATORS | net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS; } else { format_types = url_formatter::kFormatUrlOmitNothing; unescape_rules = net::UnescapeRule::NONE; } return url_formatter::FormatUrl(url_to_format, format_types, unescape_rules, nullptr, nullptr, nullptr); } void RenderViewContextMenu::WriteURLToClipboard(const GURL& url) { if (url.is_empty() || !url.is_valid()) return; ui::ScopedClipboardWriter scw(ui::ClipboardBuffer::kCopyPaste); scw.WriteText(FormatURLForClipboard(url)); } void RenderViewContextMenu::InitMenu() { RenderViewContextMenuBase::InitMenu(); AppendQuickAnswersItems(); if (content_type_->SupportsGroup( ContextMenuContentType::ITEM_GROUP_PASSWORD)) { AppendPasswordItems(); } if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PAGE)) AppendPageItems(); if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_LINK)) { AppendLinkItems(); if (params_.media_type != ContextMenuDataMediaType::kNone) menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); } bool media_image = content_type_->SupportsGroup( ContextMenuContentType::ITEM_GROUP_MEDIA_IMAGE); if (media_image) AppendImageItems(); if (content_type_->SupportsGroup( ContextMenuContentType::ITEM_GROUP_SEARCHWEBFORIMAGE)) { AppendSearchWebForImageItems(); } if (content_type_->SupportsGroup( ContextMenuContentType::ITEM_GROUP_MEDIA_VIDEO)) { AppendVideoItems(); } if (content_type_->SupportsGroup( ContextMenuContentType::ITEM_GROUP_MEDIA_AUDIO)) { AppendAudioItems(); } if (content_type_->SupportsGroup( ContextMenuContentType::ITEM_GROUP_MEDIA_CANVAS)) { AppendCanvasItems(); } if (content_type_->SupportsGroup( ContextMenuContentType::ITEM_GROUP_MEDIA_PLUGIN)) { AppendPluginItems(); } // ITEM_GROUP_MEDIA_FILE has no specific items. bool editable = content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_EDITABLE); if (editable) AppendEditableItems(); if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_COPY)) { DCHECK(!editable); AppendCopyItem(); } if (!content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_LINK)) AppendSharingItems(); if (content_type_->SupportsGroup( ContextMenuContentType::ITEM_GROUP_SEARCH_PROVIDER) && params_.misspelled_word.empty()) { AppendSearchProvider(); } if (!media_image && content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PRINT)) { AppendPrintItem(); } // Spell check and writing direction options are not currently supported by // pepper plugins. if (editable && params_.misspelled_word.empty() && !content_type_->SupportsGroup( ContextMenuContentType::ITEM_GROUP_MEDIA_PLUGIN)) { menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); AppendLanguageSettings(); AppendPlatformEditableItems(); } if (content_type_->SupportsGroup( ContextMenuContentType::ITEM_GROUP_MEDIA_PLUGIN)) { AppendRotationItems(); } bool supports_smart_text_selection = false; #if defined(OS_CHROMEOS) supports_smart_text_selection = base::FeatureList::IsEnabled(arc::kSmartTextSelectionFeature) && content_type_->SupportsGroup( ContextMenuContentType::ITEM_GROUP_SMART_SELECTION) && arc::IsArcPlayStoreEnabledForProfile(GetProfile()); #endif // defined(OS_CHROMEOS) if (supports_smart_text_selection) AppendSmartSelectionActionItems(); extension_items_.set_smart_text_selection_enabled( supports_smart_text_selection); if (content_type_->SupportsGroup( ContextMenuContentType::ITEM_GROUP_ALL_EXTENSION)) { DCHECK(!content_type_->SupportsGroup( ContextMenuContentType::ITEM_GROUP_CURRENT_EXTENSION)); AppendAllExtensionItems(); } if (content_type_->SupportsGroup( ContextMenuContentType::ITEM_GROUP_CURRENT_EXTENSION)) { DCHECK(!content_type_->SupportsGroup( ContextMenuContentType::ITEM_GROUP_ALL_EXTENSION)); AppendCurrentExtensionItems(); } // Accessibility label items are appended to all menus when a screen reader // is enabled. It can be difficult to open a specific context menu with a // screen reader, so this is a UX approved solution. bool added_accessibility_labels_items = AppendAccessibilityLabelsItems(); if (content_type_->SupportsGroup( ContextMenuContentType::ITEM_GROUP_DEVELOPER)) { AppendDeveloperItems(); } if (content_type_->SupportsGroup( ContextMenuContentType::ITEM_GROUP_DEVTOOLS_UNPACKED_EXT)) { AppendDevtoolsForUnpackedExtensions(); } if (content_type_->SupportsGroup( ContextMenuContentType::ITEM_GROUP_PRINT_PREVIEW)) { AppendPrintPreviewItems(); } // Remove any redundant trailing separator. int index = menu_model_.GetItemCount() - 1; if (index >= 0 && menu_model_.GetTypeAt(index) == ui::MenuModel::TYPE_SEPARATOR) { menu_model_.RemoveItemAt(index); } // If there is only one item and it is the Accessibility labels item, remove // it. We only show this item when it is not the only item. // Note that the separator added in AppendAccessibilityLabelsItems will not // actually be added if this is the first item in the list, so we don't need // to check for or remove the initial separator. if (added_accessibility_labels_items && menu_model_.GetItemCount() == 1) { menu_model_.RemoveItemAt(0); } } Profile* RenderViewContextMenu::GetProfile() const { return Profile::FromBrowserContext(browser_context_); } void RenderViewContextMenu::RecordUsedItem(int id) { // Log general ID. int enum_id = FindUMAEnumValueForCommand(id, UmaEnumIdLookupType::GeneralEnumId); if (enum_id == -1) { NOTREACHED() << "Update kUmaEnumToControlId. Unhanded IDC: " << id; return; } UMA_HISTOGRAM_EXACT_LINEAR( "RenderViewContextMenu.Used", enum_id, GetUmaValueMax(UmaEnumIdLookupType::GeneralEnumId)); // Log other situations. if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_LINK) && // Ignore link-related commands that don't actually open a link. IsCommandForOpenLink(id) && // Ignore using right click + open in new tab for internal links. !params_.link_url.SchemeIs(content::kChromeUIScheme)) { const GURL doc_url = GetDocumentURL(params_); const GURL history_url = GURL(chrome::kChromeUIHistoryURL); if (doc_url == history_url.Resolve(chrome::kChromeUIHistorySyncedTabs)) { UMA_HISTOGRAM_ENUMERATION( "HistoryPage.OtherDevicesMenu", browser_sync::SyncedTabsHistogram::OPENED_LINK_VIA_CONTEXT_MENU, browser_sync::SyncedTabsHistogram::LIMIT); } else if (doc_url == GURL(chrome::kChromeUIDownloadsURL)) { base::RecordAction(base::UserMetricsAction( "Downloads_OpenUrlOfDownloadedItemFromContextMenu")); } else if (doc_url == GURL(chrome::kChromeSearchLocalNtpUrl)) { base::RecordAction( base::UserMetricsAction("NTP_LinkOpenedFromContextMenu")); } else if (doc_url.GetOrigin() == chrome::kChromeSearchMostVisitedUrl) { base::RecordAction( base::UserMetricsAction("MostVisited_ClickedFromContextMenu")); } else if (doc_url.GetOrigin() == GURL(chrome::kChromeUINewTabPageURL) || doc_url.GetOrigin() == GURL(chrome::kChromeUIUntrustedNewTabPageUrl)) { base::RecordAction(base::UserMetricsAction( "NewTabPage.LinkOpenedFromContextMenu.WebUI")); } } // Log for specific contexts. Note that since the menu is displayed for // contexts (all of the ContextMenuContentType::SupportsXXX() functions), // these UMA metrics are necessarily best-effort in distilling into a context. enum_id = FindUMAEnumValueForCommand( id, UmaEnumIdLookupType::ContextSpecificEnumId); if (enum_id == -1) return; if (content_type_->SupportsGroup( ContextMenuContentType::ITEM_GROUP_MEDIA_VIDEO)) { UMA_HISTOGRAM_EXACT_LINEAR( "ContextMenu.SelectedOptionDesktop.Video", enum_id, GetUmaValueMax(UmaEnumIdLookupType::ContextSpecificEnumId)); } else if (content_type_->SupportsGroup( ContextMenuContentType::ITEM_GROUP_LINK) && content_type_->SupportsGroup( ContextMenuContentType::ITEM_GROUP_MEDIA_IMAGE)) { UMA_HISTOGRAM_EXACT_LINEAR( "ContextMenu.SelectedOptionDesktop.ImageLink", enum_id, GetUmaValueMax(UmaEnumIdLookupType::ContextSpecificEnumId)); } else if (content_type_->SupportsGroup( ContextMenuContentType::ITEM_GROUP_MEDIA_IMAGE)) { UMA_HISTOGRAM_EXACT_LINEAR( "ContextMenu.SelectedOptionDesktop.Image", enum_id, GetUmaValueMax(UmaEnumIdLookupType::ContextSpecificEnumId)); } else if (!params_.misspelled_word.empty()) { UMA_HISTOGRAM_EXACT_LINEAR( "ContextMenu.SelectedOptionDesktop.MisspelledWord", enum_id, GetUmaValueMax(UmaEnumIdLookupType::ContextSpecificEnumId)); } else if (!params_.selection_text.empty() && params_.media_type == ContextMenuDataMediaType::kNone) { // Probably just text. UMA_HISTOGRAM_EXACT_LINEAR( "ContextMenu.SelectedOptionDesktop.SelectedText", enum_id, GetUmaValueMax(UmaEnumIdLookupType::ContextSpecificEnumId)); } else { UMA_HISTOGRAM_EXACT_LINEAR( "ContextMenu.SelectedOptionDesktop.Other", enum_id, GetUmaValueMax(UmaEnumIdLookupType::ContextSpecificEnumId)); } } void RenderViewContextMenu::RecordShownItem(int id) { int enum_id = FindUMAEnumValueForCommand(id, UmaEnumIdLookupType::GeneralEnumId); if (enum_id != -1) { UMA_HISTOGRAM_EXACT_LINEAR( "RenderViewContextMenu.Shown", enum_id, GetUmaValueMax(UmaEnumIdLookupType::GeneralEnumId)); } else { // Just warning here. It's harder to maintain list of all possibly // visible items than executable items. DLOG(ERROR) << "Update kUmaEnumToControlId. Unhanded IDC: " << id; } } bool RenderViewContextMenu::IsHTML5Fullscreen() const { Browser* browser = chrome::FindBrowserWithWebContents(source_web_contents_); if (!browser) return false; FullscreenController* controller = browser->exclusive_access_manager()->fullscreen_controller(); return controller->IsTabFullscreen(); } bool RenderViewContextMenu::IsPressAndHoldEscRequiredToExitFullscreen() const { Browser* browser = chrome::FindBrowserWithWebContents(source_web_contents_); if (!browser) return false; KeyboardLockController* controller = browser->exclusive_access_manager()->keyboard_lock_controller(); return controller->RequiresPressAndHoldEscToExit(); } #if BUILDFLAG(ENABLE_PLUGINS) void RenderViewContextMenu::HandleAuthorizeAllPlugins() { ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( source_web_contents_, false, std::string()); } #endif void RenderViewContextMenu::AppendPrintPreviewItems() { #if BUILDFLAG(ENABLE_PRINT_PREVIEW) if (!print_preview_menu_observer_) { print_preview_menu_observer_ = std::make_unique<PrintPreviewContextMenuObserver>(source_web_contents_); } observers_.AddObserver(print_preview_menu_observer_.get()); #endif } const Extension* RenderViewContextMenu::GetExtension() const { return extensions::ProcessManager::Get(browser_context_) ->GetExtensionForWebContents(source_web_contents_); } std::string RenderViewContextMenu::GetTargetLanguage() const { std::unique_ptr<translate::TranslatePrefs> prefs( ChromeTranslateClient::CreateTranslatePrefs(GetPrefs(browser_context_))); language::LanguageModel* language_model = LanguageModelManagerFactory::GetForBrowserContext(browser_context_) ->GetPrimaryModel(); return translate::TranslateManager::GetTargetLanguage(prefs.get(), language_model); } void RenderViewContextMenu::AppendDeveloperItems() { // Show Inspect Element in DevTools itself only in case of the debug // devtools build. bool show_developer_items = !IsDevToolsURL(params_.page_url); #if BUILDFLAG(DEBUG_DEVTOOLS) show_developer_items = true; #endif if (!show_developer_items) return; // In the DevTools popup menu, "developer items" is normally the only // section, so omit the separator there. menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PAGE)) menu_model_.AddItemWithStringId(IDC_VIEW_SOURCE, IDS_CONTENT_CONTEXT_VIEWPAGESOURCE); if (content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_FRAME)) { menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_VIEWFRAMESOURCE, IDS_CONTENT_CONTEXT_VIEWFRAMESOURCE); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_RELOADFRAME, IDS_CONTENT_CONTEXT_RELOADFRAME); } menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_INSPECTELEMENT, IDS_CONTENT_CONTEXT_INSPECTELEMENT); } void RenderViewContextMenu::AppendDevtoolsForUnpackedExtensions() { // Add a separator if there are any items already in the menu. menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP, IDS_CONTENT_CONTEXT_RELOAD_PACKAGED_APP); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_RESTART_PACKAGED_APP, IDS_CONTENT_CONTEXT_RESTART_APP); AppendDeveloperItems(); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE, IDS_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE); } void RenderViewContextMenu::AppendLinkItems() { if (!params_.link_url.is_empty()) { const Browser* browser = GetBrowser(); const bool in_app = browser && browser->deprecated_is_app(); WebContents* active_web_contents = browser ? browser->tab_strip_model()->GetActiveWebContents() : nullptr; menu_model_.AddItemWithStringId( IDC_CONTENT_CONTEXT_OPENLINKNEWTAB, in_app ? IDS_CONTENT_CONTEXT_OPENLINKNEWTAB_INAPP : IDS_CONTENT_CONTEXT_OPENLINKNEWTAB); if (!in_app) { menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW, IDS_CONTENT_CONTEXT_OPENLINKNEWWINDOW); } if (params_.link_url.is_valid()) { AppendProtocolHandlerSubMenu(); } menu_model_.AddItemWithStringId( IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD, in_app ? IDS_CONTENT_CONTEXT_OPENLINKOFFTHERECORD_INAPP : IDS_CONTENT_CONTEXT_OPENLINKOFFTHERECORD); AppendOpenInBookmarkAppLinkItems(); AppendOpenWithLinkItems(); // While ChromeOS supports multiple profiles, only one can be open at a // time. // TODO(jochen): Consider adding support for ChromeOS with similar // semantics as the profile switcher in the system tray. #if !defined(OS_CHROMEOS) // g_browser_process->profile_manager() is null during unit tests. if (g_browser_process->profile_manager() && GetProfile()->IsRegularProfile()) { ProfileManager* profile_manager = g_browser_process->profile_manager(); // Find all regular profiles other than the current one which have at // least one open window. std::vector<ProfileAttributesEntry*> entries = profile_manager->GetProfileAttributesStorage(). GetAllProfilesAttributesSortedByName(); std::vector<ProfileAttributesEntry*> target_profiles_entries; for (ProfileAttributesEntry* entry : entries) { base::FilePath profile_path = entry->GetPath(); Profile* profile = profile_manager->GetProfileByPath(profile_path); if (profile != GetProfile() && !entry->IsOmitted() && !entry->IsSigninRequired()) { target_profiles_entries.push_back(entry); if (chrome::FindLastActiveWithProfile(profile)) multiple_profiles_open_ = true; } } if (!target_profiles_entries.empty()) { UmaEnumOpenLinkAsUserProfilesState profiles_state; if (multiple_profiles_open_) { profiles_state = OPEN_LINK_AS_USER_PROFILES_STATE_OTHER_ACTIVE_PROFILES_ENUM_ID; } else { profiles_state = OPEN_LINK_AS_USER_PROFILES_STATE_NO_OTHER_ACTIVE_PROFILES_ENUM_ID; } UMA_HISTOGRAM_ENUMERATION( "RenderViewContextMenu.OpenLinkAsUserProfilesState", profiles_state, OPEN_LINK_AS_USER_PROFILES_STATE_LAST_ENUM_ID); UMA_HISTOGRAM_ENUMERATION("RenderViewContextMenu.OpenLinkAsUserShown", target_profiles_entries.size(), kOpenLinkAsUserMaxProfilesReported); } if (multiple_profiles_open_ && !target_profiles_entries.empty()) { if (target_profiles_entries.size() == 1) { int menu_index = static_cast<int>(profile_link_paths_.size()); ProfileAttributesEntry* entry = target_profiles_entries.front(); profile_link_paths_.push_back(entry->GetPath()); menu_model_.AddItem( IDC_OPEN_LINK_IN_PROFILE_FIRST + menu_index, l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_OPENLINKINPROFILE, entry->GetName())); AddAvatarToLastMenuItem(entry->GetAvatarIcon(), &menu_model_); } else { for (ProfileAttributesEntry* entry : target_profiles_entries) { int menu_index = static_cast<int>(profile_link_paths_.size()); // In extreme cases, we might have more profiles than available // command ids. In that case, just stop creating new entries - the // menu is probably useless at this point already. if (IDC_OPEN_LINK_IN_PROFILE_FIRST + menu_index > IDC_OPEN_LINK_IN_PROFILE_LAST) { break; } profile_link_paths_.push_back(entry->GetPath()); profile_link_submenu_model_.AddItem( IDC_OPEN_LINK_IN_PROFILE_FIRST + menu_index, entry->GetName()); AddAvatarToLastMenuItem(entry->GetAvatarIcon(), &profile_link_submenu_model_); } menu_model_.AddSubMenuWithStringId( IDC_CONTENT_CONTEXT_OPENLINKINPROFILE, IDS_CONTENT_CONTEXT_OPENLINKINPROFILES, &profile_link_submenu_model_); } } } #endif // !defined(OS_CHROMEOS) menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); if (browser && send_tab_to_self::ShouldOfferFeatureForLink( active_web_contents, params_.link_url)) { send_tab_to_self::RecordSendTabToSelfClickResult( send_tab_to_self::kLinkMenu, SendTabToSelfClickResult::kShowItem); if (send_tab_to_self::GetValidDeviceCount(GetBrowser()->profile()) == 1) { #if defined(OS_MACOSX) menu_model_.AddItem(IDC_CONTENT_LINK_SEND_TAB_TO_SELF_SINGLE_TARGET, l10n_util::GetStringFUTF16( IDS_LINK_MENU_SEND_TAB_TO_SELF_SINGLE_TARGET, send_tab_to_self::GetSingleTargetDeviceName( GetBrowser()->profile()))); #else menu_model_.AddItemWithIcon( IDC_CONTENT_LINK_SEND_TAB_TO_SELF_SINGLE_TARGET, l10n_util::GetStringFUTF16( IDS_LINK_MENU_SEND_TAB_TO_SELF_SINGLE_TARGET, send_tab_to_self::GetSingleTargetDeviceName( GetBrowser()->profile())), ui::ImageModel::FromVectorIcon(kSendTabToSelfIcon)); #endif send_tab_to_self::RecordSendTabToSelfClickResult( send_tab_to_self::kLinkMenu, SendTabToSelfClickResult::kShowDeviceList); send_tab_to_self::RecordSendTabToSelfDeviceCount( send_tab_to_self::kLinkMenu, 1); } else { send_tab_to_self_sub_menu_model_ = std::make_unique<send_tab_to_self::SendTabToSelfSubMenuModel>( active_web_contents, send_tab_to_self::SendTabToSelfMenuType::kLink, params_.link_url); #if defined(OS_MACOSX) menu_model_.AddSubMenuWithStringId( IDC_CONTENT_LINK_SEND_TAB_TO_SELF, IDS_LINK_MENU_SEND_TAB_TO_SELF, send_tab_to_self_sub_menu_model_.get()); #else menu_model_.AddSubMenuWithStringIdAndIcon( IDC_CONTENT_LINK_SEND_TAB_TO_SELF, IDS_LINK_MENU_SEND_TAB_TO_SELF, send_tab_to_self_sub_menu_model_.get(), ui::ImageModel::FromVectorIcon(kSendTabToSelfIcon)); #endif } } AppendClickToCallItem(); menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVELINKAS, IDS_CONTENT_CONTEXT_SAVELINKAS); } menu_model_.AddItemWithStringId( IDC_CONTENT_CONTEXT_COPYLINKLOCATION, params_.link_url.SchemeIs(url::kMailToScheme) ? IDS_CONTENT_CONTEXT_COPYEMAILADDRESS : IDS_CONTENT_CONTEXT_COPYLINKLOCATION); if (params_.source_type == ui::MENU_SOURCE_TOUCH && params_.media_type != ContextMenuDataMediaType::kImage && !params_.link_text.empty()) { menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYLINKTEXT, IDS_CONTENT_CONTEXT_COPYLINKTEXT); } } void RenderViewContextMenu::AppendOpenWithLinkItems() { #if defined(OS_CHROMEOS) open_with_menu_observer_ = std::make_unique<arc::OpenWithMenu>(browser_context_, this); observers_.AddObserver(open_with_menu_observer_.get()); open_with_menu_observer_->InitMenu(params_); #endif } void RenderViewContextMenu::AppendQuickAnswersItems() { #if defined(OS_CHROMEOS) if (!quick_answers_menu_observer_) { quick_answers_menu_observer_ = std::make_unique<QuickAnswersMenuObserver>(this); } observers_.AddObserver(quick_answers_menu_observer_.get()); quick_answers_menu_observer_->InitMenu(params_); #endif } void RenderViewContextMenu::AppendSmartSelectionActionItems() { #if defined(OS_CHROMEOS) start_smart_selection_action_menu_observer_ = std::make_unique<arc::StartSmartSelectionActionMenu>(this); observers_.AddObserver(start_smart_selection_action_menu_observer_.get()); if (menu_model_.GetItemCount()) menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); start_smart_selection_action_menu_observer_->InitMenu(params_); #endif } void RenderViewContextMenu::AppendOpenInBookmarkAppLinkItems() { Profile* const profile = Profile::FromBrowserContext(browser_context_); base::Optional<web_app::AppId> app_id = web_app::FindInstalledAppWithUrlInScope(profile, params_.link_url); if (!app_id) return; int open_in_app_string_id; const Browser* browser = GetBrowser(); if (browser && browser->app_name() == web_app::GenerateApplicationNameFromAppId(*app_id)) { open_in_app_string_id = IDS_CONTENT_CONTEXT_OPENLINKBOOKMARKAPP_SAMEAPP; } else { open_in_app_string_id = IDS_CONTENT_CONTEXT_OPENLINKBOOKMARKAPP; } auto* provider = web_app::WebAppProviderBase::GetProviderBase(profile); menu_model_.AddItem( IDC_CONTENT_CONTEXT_OPENLINKBOOKMARKAPP, l10n_util::GetStringFUTF16( open_in_app_string_id, base::UTF8ToUTF16(provider->registrar().GetAppShortName(*app_id)))); MenuManager* menu_manager = MenuManager::Get(browser_context_); // TODO(crbug.com/1052707): Use AppIconManager to read PWA icons. gfx::Image icon = menu_manager->GetIconForExtension(*app_id); menu_model_.SetIcon(menu_model_.GetItemCount() - 1, ui::ImageModel::FromImage(icon)); } void RenderViewContextMenu::AppendImageItems() { if (!params_.has_image_contents) { menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_LOAD_IMAGE, IDS_CONTENT_CONTEXT_LOAD_IMAGE); } menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB, IDS_CONTENT_CONTEXT_OPENIMAGENEWTAB); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEIMAGEAS, IDS_CONTENT_CONTEXT_SAVEIMAGEAS); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYIMAGE, IDS_CONTENT_CONTEXT_COPYIMAGE); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYIMAGELOCATION, IDS_CONTENT_CONTEXT_COPYIMAGELOCATION); } void RenderViewContextMenu::AppendSearchWebForImageItems() { if (!params_.has_image_contents) return; TemplateURLService* service = TemplateURLServiceFactory::GetForProfile(GetProfile()); const TemplateURL* const provider = service->GetDefaultSearchProvider(); if (!provider || provider->image_url().empty() || !provider->image_url_ref().IsValid(service->search_terms_data())) { return; } menu_model_.AddItem( IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE, l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_SEARCHWEBFORIMAGE, provider->short_name())); } void RenderViewContextMenu::AppendAudioItems() { AppendMediaItems(); menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENAVNEWTAB, IDS_CONTENT_CONTEXT_OPENAUDIONEWTAB); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEAVAS, IDS_CONTENT_CONTEXT_SAVEAUDIOAS); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYAVLOCATION, IDS_CONTENT_CONTEXT_COPYAUDIOLOCATION); AppendMediaRouterItem(); } void RenderViewContextMenu::AppendCanvasItems() { menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEIMAGEAS, IDS_CONTENT_CONTEXT_SAVEIMAGEAS); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYIMAGE, IDS_CONTENT_CONTEXT_COPYIMAGE); } void RenderViewContextMenu::AppendVideoItems() { AppendMediaItems(); menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENAVNEWTAB, IDS_CONTENT_CONTEXT_OPENVIDEONEWTAB); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEAVAS, IDS_CONTENT_CONTEXT_SAVEVIDEOAS); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYAVLOCATION, IDS_CONTENT_CONTEXT_COPYVIDEOLOCATION); AppendPictureInPictureItem(); AppendMediaRouterItem(); } void RenderViewContextMenu::AppendMediaItems() { menu_model_.AddCheckItemWithStringId(IDC_CONTENT_CONTEXT_LOOP, IDS_CONTENT_CONTEXT_LOOP); menu_model_.AddCheckItemWithStringId(IDC_CONTENT_CONTEXT_CONTROLS, IDS_CONTENT_CONTEXT_CONTROLS); } void RenderViewContextMenu::AppendPluginItems() { if (params_.page_url == params_.src_url || (guest_view::GuestViewBase::IsGuest(source_web_contents_) && (!embedder_web_contents_ || !embedder_web_contents_->IsSavable()))) { // Both full page and embedded plugins are hosted as guest now, // the difference is a full page plugin is not considered as savable. // For full page plugin, we show page menu items so long as focus is not // within an editable text area. if (params_.link_url.is_empty() && params_.selection_text.empty() && !params_.is_editable) { AppendPageItems(); } } else { menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEAVAS, IDS_CONTENT_CONTEXT_SAVEPAGEAS); // The "Print" menu item should always be included for plugins. If // content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PRINT) // is true the item will be added inside AppendPrintItem(). Otherwise we // add "Print" here. if (!content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PRINT)) menu_model_.AddItemWithStringId(IDC_PRINT, IDS_CONTENT_CONTEXT_PRINT); } } void RenderViewContextMenu::AppendPageItems() { AppendExitFullscreenItem(); menu_model_.AddItemWithStringId(IDC_BACK, IDS_CONTENT_CONTEXT_BACK); menu_model_.AddItemWithStringId(IDC_FORWARD, IDS_CONTENT_CONTEXT_FORWARD); menu_model_.AddItemWithStringId(IDC_RELOAD, IDS_CONTENT_CONTEXT_RELOAD); menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); menu_model_.AddItemWithStringId(IDC_SAVE_PAGE, IDS_CONTENT_CONTEXT_SAVEPAGEAS); menu_model_.AddItemWithStringId(IDC_PRINT, IDS_CONTENT_CONTEXT_PRINT); AppendMediaRouterItem(); // Send-Tab-To-Self (user's other devices), page level. bool send_tab_to_self_menu_present = false; if (GetBrowser() && send_tab_to_self::ShouldOfferFeature( GetBrowser()->tab_strip_model()->GetActiveWebContents())) { send_tab_to_self::RecordSendTabToSelfClickResult( send_tab_to_self::kContentMenu, SendTabToSelfClickResult::kShowItem); menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); send_tab_to_self_menu_present = true; if (send_tab_to_self::GetValidDeviceCount(GetBrowser()->profile()) == 1) { #if defined(OS_MACOSX) menu_model_.AddItem(IDC_SEND_TAB_TO_SELF_SINGLE_TARGET, l10n_util::GetStringFUTF16( IDS_CONTEXT_MENU_SEND_TAB_TO_SELF_SINGLE_TARGET, send_tab_to_self::GetSingleTargetDeviceName( GetBrowser()->profile()))); #else menu_model_.AddItemWithIcon( IDC_SEND_TAB_TO_SELF_SINGLE_TARGET, l10n_util::GetStringFUTF16( IDS_CONTEXT_MENU_SEND_TAB_TO_SELF_SINGLE_TARGET, send_tab_to_self::GetSingleTargetDeviceName( GetBrowser()->profile())), ui::ImageModel::FromVectorIcon(kSendTabToSelfIcon)); #endif send_tab_to_self::RecordSendTabToSelfClickResult( send_tab_to_self::kContentMenu, SendTabToSelfClickResult::kShowDeviceList); send_tab_to_self::RecordSendTabToSelfDeviceCount( send_tab_to_self::kContentMenu, 1); } else { send_tab_to_self_sub_menu_model_ = std::make_unique<send_tab_to_self::SendTabToSelfSubMenuModel>( GetBrowser()->tab_strip_model()->GetActiveWebContents(), send_tab_to_self::SendTabToSelfMenuType::kContent); #if defined(OS_MACOSX) menu_model_.AddSubMenuWithStringId( IDC_SEND_TAB_TO_SELF, IDS_CONTEXT_MENU_SEND_TAB_TO_SELF, send_tab_to_self_sub_menu_model_.get()); #else menu_model_.AddSubMenuWithStringIdAndIcon( IDC_SEND_TAB_TO_SELF, IDS_CONTEXT_MENU_SEND_TAB_TO_SELF, send_tab_to_self_sub_menu_model_.get(), ui::ImageModel::FromVectorIcon(kSendTabToSelfIcon)); #endif } } // Context menu item for QR Code Generator. if (IsQRCodeGeneratorEnabled()) { // This is presented alongside the send-tab-to-self items, though each may // be present without the other due to feature experimentation. Therefore we // may or may not need to create a new separator. if (!send_tab_to_self_menu_present) menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); #if defined(OS_MACOSX) menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_GENERATE_QR_CODE, IDS_CONTEXT_MENU_GENERATE_QR_CODE_PAGE); #else menu_model_.AddItemWithStringIdAndIcon( IDC_CONTENT_CONTEXT_GENERATE_QR_CODE, IDS_CONTEXT_MENU_GENERATE_QR_CODE_PAGE, ui::ImageModel::FromVectorIcon(kQrcodeGeneratorIcon)); #endif menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); } else if (send_tab_to_self_menu_present) { // Close out sharing section if send-tab-to-self was present but QR // generator was not. menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); } if (TranslateService::IsTranslatableURL(params_.page_url)) { std::unique_ptr<translate::TranslatePrefs> prefs( ChromeTranslateClient::CreateTranslatePrefs( GetPrefs(browser_context_))); if (prefs->IsTranslateAllowedByPolicy()) { language::LanguageModel* language_model = LanguageModelManagerFactory::GetForBrowserContext(browser_context_) ->GetPrimaryModel(); std::string locale = translate::TranslateManager::GetTargetLanguage( prefs.get(), language_model); base::string16 language = l10n_util::GetDisplayNameForLocale(locale, locale, true); menu_model_.AddItem( IDC_CONTENT_CONTEXT_TRANSLATE, l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_TRANSLATE, language)); } } } void RenderViewContextMenu::AppendExitFullscreenItem() { Browser* browser = GetBrowser(); if (!browser) return; // Only show item if in fullscreen mode. if (!browser->exclusive_access_manager() ->fullscreen_controller() ->IsControllerInitiatedFullscreen()) { return; } menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_EXIT_FULLSCREEN, IDS_CONTENT_CONTEXT_EXIT_FULLSCREEN); menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); } void RenderViewContextMenu::AppendCopyItem() { if (menu_model_.GetItemCount()) menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPY, IDS_CONTENT_CONTEXT_COPY); } void RenderViewContextMenu::AppendPrintItem() { if (GetPrefs(browser_context_)->GetBoolean(prefs::kPrintingEnabled) && (params_.media_type == ContextMenuDataMediaType::kNone || params_.media_flags & WebContextMenuData::kMediaCanPrint) && params_.misspelled_word.empty()) { menu_model_.AddItemWithStringId(IDC_PRINT, IDS_CONTENT_CONTEXT_PRINT); } } void RenderViewContextMenu::AppendMediaRouterItem() { if (media_router::MediaRouterEnabled(browser_context_)) { menu_model_.AddItemWithStringId(IDC_ROUTE_MEDIA, IDS_MEDIA_ROUTER_MENU_ITEM_TITLE); } } void RenderViewContextMenu::AppendRotationItems() { if (params_.media_flags & WebContextMenuData::kMediaCanRotate) { menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ROTATECW, IDS_CONTENT_CONTEXT_ROTATECW); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ROTATECCW, IDS_CONTENT_CONTEXT_ROTATECCW); } } void RenderViewContextMenu::AppendSearchProvider() { DCHECK(browser_context_); base::TrimWhitespace(params_.selection_text, base::TRIM_ALL, &params_.selection_text); if (params_.selection_text.empty()) return; base::ReplaceChars(params_.selection_text, AutocompleteMatch::kInvalidChars, base::ASCIIToUTF16(" "), &params_.selection_text); AutocompleteMatch match; AutocompleteClassifierFactory::GetForProfile(GetProfile()) ->Classify(params_.selection_text, false, false, metrics::OmniboxEventProto::INVALID_SPEC, &match, nullptr); selection_navigation_url_ = match.destination_url; if (!selection_navigation_url_.is_valid()) return; base::string16 printable_selection_text = PrintableSelectionText(); EscapeAmpersands(&printable_selection_text); if (AutocompleteMatch::IsSearchType(match.type)) { const TemplateURL* const default_provider = TemplateURLServiceFactory::GetForProfile(GetProfile()) ->GetDefaultSearchProvider(); if (!default_provider) return; menu_model_.AddItem( IDC_CONTENT_CONTEXT_SEARCHWEBFOR, l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_SEARCHWEBFOR, default_provider->short_name(), printable_selection_text)); } else { if ((selection_navigation_url_ != params_.link_url) && ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme( selection_navigation_url_.scheme())) { menu_model_.AddItem( IDC_CONTENT_CONTEXT_GOTOURL, l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_GOTOURL, printable_selection_text)); } } } void RenderViewContextMenu::AppendEditableItems() { const bool use_spelling = !chrome::IsRunningInForcedAppMode(); if (use_spelling) AppendSpellingSuggestionItems(); if (!params_.misspelled_word.empty()) { AppendSearchProvider(); menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); } if (params_.misspelled_word.empty() && DoesInputFieldTypeSupportEmoji(params_.input_field_type) && ui::IsEmojiPanelSupported()) { menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_EMOJI, IDS_CONTENT_CONTEXT_EMOJI); menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); } // 'Undo' and 'Redo' for text input with no suggestions and no text selected. // We make an exception for OS X as context clicking will select the closest // word. In this case both items are always shown. #if defined(OS_MACOSX) menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_UNDO, IDS_CONTENT_CONTEXT_UNDO); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_REDO, IDS_CONTENT_CONTEXT_REDO); menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); #else // Also want to show 'Undo' and 'Redo' if 'Emoji' is the only item in the menu // so far. if (!IsDevToolsURL(params_.page_url) && !content_type_->SupportsGroup(ContextMenuContentType::ITEM_GROUP_PRINT) && (!menu_model_.GetItemCount() || menu_model_.GetIndexOfCommandId(IDC_CONTENT_CONTEXT_EMOJI) != -1)) { menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_UNDO, IDS_CONTENT_CONTEXT_UNDO); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_REDO, IDS_CONTENT_CONTEXT_REDO); menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); } #endif menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_CUT, IDS_CONTENT_CONTEXT_CUT); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPY, IDS_CONTENT_CONTEXT_COPY); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_PASTE, IDS_CONTENT_CONTEXT_PASTE); if (params_.misspelled_word.empty()) { menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE, IDS_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SELECTALL, IDS_CONTENT_CONTEXT_SELECTALL); } menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); } void RenderViewContextMenu::AppendLanguageSettings() { const bool use_spelling = !chrome::IsRunningInForcedAppMode(); if (!use_spelling) return; #if defined(OS_MACOSX) menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS, IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS); #else if (!spelling_options_submenu_observer_) { const int kLanguageRadioGroup = 1; spelling_options_submenu_observer_ = std::make_unique<SpellingOptionsSubMenuObserver>(this, this, kLanguageRadioGroup); } spelling_options_submenu_observer_->InitMenu(params_); observers_.AddObserver(spelling_options_submenu_observer_.get()); #endif } void RenderViewContextMenu::AppendSpellingSuggestionItems() { if (!spelling_suggestions_menu_observer_) { spelling_suggestions_menu_observer_ = std::make_unique<SpellingMenuObserver>(this); } observers_.AddObserver(spelling_suggestions_menu_observer_.get()); spelling_suggestions_menu_observer_->InitMenu(params_); } bool RenderViewContextMenu::AppendAccessibilityLabelsItems() { menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); if (!accessibility_labels_menu_observer_) { accessibility_labels_menu_observer_ = std::make_unique<AccessibilityLabelsMenuObserver>(this); } observers_.AddObserver(accessibility_labels_menu_observer_.get()); accessibility_labels_menu_observer_->InitMenu(params_); return accessibility_labels_menu_observer_->ShouldShowLabelsItem(); } void RenderViewContextMenu::AppendProtocolHandlerSubMenu() { const ProtocolHandlerRegistry::ProtocolHandlerList handlers = GetHandlersForLinkUrl(); if (handlers.empty()) return; size_t max = IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST - IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST; for (size_t i = 0; i < handlers.size() && i <= max; i++) { protocol_handler_submenu_model_.AddItem( IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST + i, base::UTF8ToUTF16(handlers[i].url().host())); } protocol_handler_submenu_model_.AddSeparator(ui::NORMAL_SEPARATOR); protocol_handler_submenu_model_.AddItem( IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS, l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_OPENLINKWITH_CONFIGURE)); menu_model_.AddSubMenu( IDC_CONTENT_CONTEXT_OPENLINKWITH, l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_OPENLINKWITH), &protocol_handler_submenu_model_); } void RenderViewContextMenu::AppendPasswordItems() { bool add_separator = false; password_manager::ContentPasswordManagerDriver* driver = password_manager::ContentPasswordManagerDriver::GetForRenderFrameHost( GetRenderFrameHost()); // Don't show the item for guest or incognito profiles and also when the // automatic generation feature is disabled. if (password_manager_util::ManualPasswordGenerationEnabled(driver)) { menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_GENERATEPASSWORD, IDS_CONTENT_CONTEXT_GENERATEPASSWORD); add_separator = true; } if (password_manager_util::ShowAllSavedPasswordsContextMenuEnabled(driver)) { menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SHOWALLSAVEDPASSWORDS, IDS_AUTOFILL_SHOW_ALL_SAVED_FALLBACK); add_separator = true; } if (add_separator) menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); } void RenderViewContextMenu::AppendPictureInPictureItem() { if (base::FeatureList::IsEnabled(media::kPictureInPicture)) menu_model_.AddCheckItemWithStringId(IDC_CONTENT_CONTEXT_PICTUREINPICTURE, IDS_CONTENT_CONTEXT_PICTUREINPICTURE); } void RenderViewContextMenu::AppendSharingItems() { int items_initial = menu_model_.GetItemCount(); menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); // Check if the starting separator got added. int items_before_sharing = menu_model_.GetItemCount(); bool starting_separator_added = items_before_sharing > items_initial; AppendClickToCallItem(); AppendSharedClipboardItem(); // Add an ending separator if there are sharing items, otherwise remove the // starting separator iff we added one above. int sharing_items = menu_model_.GetItemCount() - items_before_sharing; if (sharing_items > 0) menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); else if (starting_separator_added) menu_model_.RemoveItemAt(items_initial); } void RenderViewContextMenu::AppendClickToCallItem() { SharingClickToCallEntryPoint entry_point; base::Optional<std::string> phone_number; std::string selection_text; if (ShouldOfferClickToCallForURL(browser_context_, params_.link_url)) { entry_point = SharingClickToCallEntryPoint::kRightClickLink; phone_number = GetUnescapedURLContent(params_.link_url); } else if (!params_.selection_text.empty()) { entry_point = SharingClickToCallEntryPoint::kRightClickSelection; selection_text = base::UTF16ToUTF8(params_.selection_text); phone_number = ExtractPhoneNumberForClickToCall(browser_context_, selection_text); } if (!phone_number || phone_number->empty()) return; if (!click_to_call_context_menu_observer_) { click_to_call_context_menu_observer_ = std::make_unique<ClickToCallContextMenuObserver>(this); observers_.AddObserver(click_to_call_context_menu_observer_.get()); } click_to_call_context_menu_observer_->BuildMenu(*phone_number, selection_text, entry_point); } void RenderViewContextMenu::AppendSharedClipboardItem() { if (!ShouldOfferSharedClipboard(browser_context_, params_.selection_text)) return; if (!shared_clipboard_context_menu_observer_) { shared_clipboard_context_menu_observer_ = std::make_unique<SharedClipboardContextMenuObserver>(this); observers_.AddObserver(shared_clipboard_context_menu_observer_.get()); } shared_clipboard_context_menu_observer_->InitMenu(params_); } // Menu delegate functions ----------------------------------------------------- bool RenderViewContextMenu::IsCommandIdEnabled(int id) const { // Disable context menu in locked fullscreen mode (the menu is not really // disabled as the user can still open it, but all the individual context menu // entries are disabled / greyed out). if (GetBrowser() && platform_util::IsBrowserLockedFullscreen(GetBrowser())) return false; { bool enabled = false; if (RenderViewContextMenuBase::IsCommandIdKnown(id, &enabled)) return enabled; } CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(source_web_contents_); int content_restrictions = 0; if (core_tab_helper) content_restrictions = core_tab_helper->content_restrictions(); if (id == IDC_PRINT && (content_restrictions & CONTENT_RESTRICTION_PRINT)) return false; if (id == IDC_SAVE_PAGE && (content_restrictions & CONTENT_RESTRICTION_SAVE)) { return false; } PrefService* prefs = GetPrefs(browser_context_); // Allow Spell Check language items on sub menu for text area context menu. if ((id >= IDC_SPELLCHECK_LANGUAGES_FIRST) && (id < IDC_SPELLCHECK_LANGUAGES_LAST)) { return prefs->GetBoolean(spellcheck::prefs::kSpellCheckEnable); } // Extension items. if (ContextMenuMatcher::IsExtensionsCustomCommandId(id)) return extension_items_.IsCommandIdEnabled(id); if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST && id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) { return true; } if (id >= IDC_OPEN_LINK_IN_PROFILE_FIRST && id <= IDC_OPEN_LINK_IN_PROFILE_LAST) { return params_.link_url.is_valid(); } switch (id) { case IDC_BACK: return embedder_web_contents_->GetController().CanGoBack(); case IDC_FORWARD: return embedder_web_contents_->GetController().CanGoForward(); case IDC_RELOAD: return IsReloadEnabled(); case IDC_VIEW_SOURCE: case IDC_CONTENT_CONTEXT_VIEWFRAMESOURCE: return IsViewSourceEnabled(); case IDC_CONTENT_CONTEXT_INSPECTELEMENT: case IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE: case IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP: case IDC_CONTENT_CONTEXT_RESTART_PACKAGED_APP: return IsDevCommandEnabled(id); case IDC_CONTENT_CONTEXT_TRANSLATE: return IsTranslateEnabled(); case IDC_CONTENT_CONTEXT_OPENLINKNEWTAB: case IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW: case IDC_CONTENT_CONTEXT_OPENLINKINPROFILE: case IDC_CONTENT_CONTEXT_OPENLINKBOOKMARKAPP: return params_.link_url.is_valid(); case IDC_CONTENT_CONTEXT_COPYLINKLOCATION: return params_.unfiltered_link_url.is_valid(); case IDC_CONTENT_CONTEXT_COPYLINKTEXT: return true; case IDC_CONTENT_CONTEXT_SAVELINKAS: return IsSaveLinkAsEnabled(); case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: return IsSaveImageAsEnabled(); // The images shown in the most visited thumbnails can't be opened or // searched for conventionally. case IDC_CONTENT_CONTEXT_OPEN_ORIGINAL_IMAGE_NEW_TAB: case IDC_CONTENT_CONTEXT_LOAD_IMAGE: case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB: case IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE: return params_.src_url.is_valid() && (params_.src_url.scheme() != content::kChromeUIScheme); case IDC_CONTENT_CONTEXT_COPYIMAGE: return params_.has_image_contents; // Media control commands should all be disabled if the player is in an // error state. case IDC_CONTENT_CONTEXT_PLAYPAUSE: return (params_.media_flags & WebContextMenuData::kMediaInError) == 0; // Loop command should be disabled if the player is in an error state. case IDC_CONTENT_CONTEXT_LOOP: return (params_.media_flags & WebContextMenuData::kMediaCanLoop) != 0 && (params_.media_flags & WebContextMenuData::kMediaInError) == 0; // Mute and unmute should also be disabled if the player has no audio. case IDC_CONTENT_CONTEXT_MUTE: return (params_.media_flags & WebContextMenuData::kMediaHasAudio) != 0 && (params_.media_flags & WebContextMenuData::kMediaInError) == 0; case IDC_CONTENT_CONTEXT_CONTROLS: return (params_.media_flags & WebContextMenuData::kMediaCanToggleControls) != 0; case IDC_CONTENT_CONTEXT_ROTATECW: case IDC_CONTENT_CONTEXT_ROTATECCW: return (params_.media_flags & WebContextMenuData::kMediaCanRotate) != 0; case IDC_CONTENT_CONTEXT_COPYAVLOCATION: case IDC_CONTENT_CONTEXT_COPYIMAGELOCATION: return params_.src_url.is_valid(); case IDC_CONTENT_CONTEXT_SAVEAVAS: return IsSaveAsEnabled(); case IDC_CONTENT_CONTEXT_OPENAVNEWTAB: // Currently, a media element can be opened in a new tab iff it can // be saved. So rather than duplicating the MediaCanSave flag, we rely // on that here. return !!(params_.media_flags & WebContextMenuData::kMediaCanSave); case IDC_SAVE_PAGE: return IsSavePageEnabled(); case IDC_CONTENT_CONTEXT_RELOADFRAME: return params_.frame_url.is_valid() && params_.frame_url.GetOrigin() != chrome::kChromeUIPrintURL; case IDC_CONTENT_CONTEXT_UNDO: return !!(params_.edit_flags & ContextMenuDataEditFlags::kCanUndo); case IDC_CONTENT_CONTEXT_REDO: return !!(params_.edit_flags & ContextMenuDataEditFlags::kCanRedo); case IDC_CONTENT_CONTEXT_CUT: return !!(params_.edit_flags & ContextMenuDataEditFlags::kCanCut); case IDC_CONTENT_CONTEXT_COPY: return !!(params_.edit_flags & ContextMenuDataEditFlags::kCanCopy); case IDC_CONTENT_CONTEXT_PASTE: return IsPasteEnabled(); case IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE: return IsPasteAndMatchStyleEnabled(); case IDC_CONTENT_CONTEXT_DELETE: return !!(params_.edit_flags & ContextMenuDataEditFlags::kCanDelete); case IDC_CONTENT_CONTEXT_SELECTALL: return !!(params_.edit_flags & ContextMenuDataEditFlags::kCanSelectAll); case IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD: return IsOpenLinkOTREnabled(); case IDC_PRINT: return IsPrintPreviewEnabled(); case IDC_CONTENT_CONTEXT_SEARCHWEBFOR: case IDC_CONTENT_CONTEXT_GOTOURL: case IDC_SPELLPANEL_TOGGLE: case IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS: case IDC_SEND_TAB_TO_SELF: case IDC_SEND_TAB_TO_SELF_SINGLE_TARGET: return true; case IDC_CONTENT_CONTEXT_GENERATE_QR_CODE: return IsQRCodeGeneratorEnabled(); case IDC_CONTENT_LINK_SEND_TAB_TO_SELF: case IDC_CONTENT_LINK_SEND_TAB_TO_SELF_SINGLE_TARGET: return send_tab_to_self::AreContentRequirementsMet( params_.link_url, GetBrowser()->profile()); case IDC_CHECK_SPELLING_WHILE_TYPING: return prefs->GetBoolean(spellcheck::prefs::kSpellCheckEnable); #if !defined(OS_MACOSX) && defined(OS_POSIX) // TODO(suzhe): this should not be enabled for password fields. case IDC_INPUT_METHODS_MENU: return true; #endif case IDC_SPELLCHECK_MENU: case IDC_CONTENT_CONTEXT_OPENLINKWITH: case IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS: case IDC_CONTENT_CONTEXT_GENERATEPASSWORD: case IDC_CONTENT_CONTEXT_SHOWALLSAVEDPASSWORDS: return true; case IDC_ROUTE_MEDIA: return IsRouteMediaEnabled(); case IDC_CONTENT_CONTEXT_EXIT_FULLSCREEN: return true; case IDC_CONTENT_CONTEXT_PICTUREINPICTURE: return !!(params_.media_flags & WebContextMenuData::kMediaCanPictureInPicture); case IDC_CONTENT_CONTEXT_EMOJI: return params_.is_editable; case IDC_CONTENT_CONTEXT_START_SMART_SELECTION_ACTION1: case IDC_CONTENT_CONTEXT_START_SMART_SELECTION_ACTION2: case IDC_CONTENT_CONTEXT_START_SMART_SELECTION_ACTION3: case IDC_CONTENT_CONTEXT_START_SMART_SELECTION_ACTION4: case IDC_CONTENT_CONTEXT_START_SMART_SELECTION_ACTION5: return true; default: NOTREACHED(); return false; } } bool RenderViewContextMenu::IsCommandIdChecked(int id) const { if (RenderViewContextMenuBase::IsCommandIdChecked(id)) return true; // See if the video is set to looping. if (id == IDC_CONTENT_CONTEXT_LOOP) return (params_.media_flags & WebContextMenuData::kMediaLoop) != 0; if (id == IDC_CONTENT_CONTEXT_CONTROLS) return (params_.media_flags & WebContextMenuData::kMediaControls) != 0; if (id == IDC_CONTENT_CONTEXT_PICTUREINPICTURE) return (params_.media_flags & WebContextMenuData::kMediaPictureInPicture) != 0; if (id == IDC_CONTENT_CONTEXT_EMOJI) return false; // Extension items. if (ContextMenuMatcher::IsExtensionsCustomCommandId(id)) return extension_items_.IsCommandIdChecked(id); return false; } bool RenderViewContextMenu::IsCommandIdVisible(int id) const { if (ContextMenuMatcher::IsExtensionsCustomCommandId(id)) return extension_items_.IsCommandIdVisible(id); return RenderViewContextMenuBase::IsCommandIdVisible(id); } void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) { RenderViewContextMenuBase::ExecuteCommand(id, event_flags); if (command_executed_) return; command_executed_ = true; // Process extension menu items. if (ContextMenuMatcher::IsExtensionsCustomCommandId(id)) { RenderFrameHost* render_frame_host = GetRenderFrameHost(); if (render_frame_host) { extension_items_.ExecuteCommand(id, source_web_contents_, render_frame_host, params_); } return; } if (id >= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST && id <= IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_LAST) { ExecProtocolHandler(event_flags, id - IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST); return; } if (id >= IDC_OPEN_LINK_IN_PROFILE_FIRST && id <= IDC_OPEN_LINK_IN_PROFILE_LAST) { ExecOpenLinkInProfile(id - IDC_OPEN_LINK_IN_PROFILE_FIRST); return; } switch (id) { case IDC_CONTENT_CONTEXT_OPENLINKNEWTAB: OpenURLWithExtraHeaders(params_.link_url, GetDocumentURL(params_), WindowOpenDisposition::NEW_BACKGROUND_TAB, ui::PAGE_TRANSITION_LINK, "" /* extra_headers */, true /* started_from_context_menu */); break; case IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW: OpenURLWithExtraHeaders(params_.link_url, GetDocumentURL(params_), WindowOpenDisposition::NEW_WINDOW, ui::PAGE_TRANSITION_LINK, "" /* extra_headers */, true /* started_from_context_menu */); break; case IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD: OpenURLWithExtraHeaders(params_.link_url, GURL(), WindowOpenDisposition::OFF_THE_RECORD, ui::PAGE_TRANSITION_LINK, "" /* extra_headers */, true /* started_from_context_menu */); break; case IDC_CONTENT_CONTEXT_OPENLINKBOOKMARKAPP: ExecOpenBookmarkApp(); break; case IDC_CONTENT_CONTEXT_SAVELINKAS: ExecSaveLinkAs(); break; case IDC_CONTENT_CONTEXT_SAVEAVAS: case IDC_CONTENT_CONTEXT_SAVEIMAGEAS: ExecSaveAs(); break; case IDC_CONTENT_CONTEXT_COPYLINKLOCATION: WriteURLToClipboard(params_.unfiltered_link_url); break; case IDC_CONTENT_CONTEXT_COPYLINKTEXT: ExecCopyLinkText(); break; case IDC_CONTENT_CONTEXT_COPYIMAGELOCATION: case IDC_CONTENT_CONTEXT_COPYAVLOCATION: WriteURLToClipboard(params_.src_url); break; case IDC_CONTENT_CONTEXT_COPYIMAGE: ExecCopyImageAt(); break; case IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE: ExecSearchWebForImage(); break; case IDC_CONTENT_CONTEXT_OPEN_ORIGINAL_IMAGE_NEW_TAB: OpenURLWithExtraHeaders(params_.src_url, GetDocumentURL(params_), WindowOpenDisposition::NEW_BACKGROUND_TAB, ui::PAGE_TRANSITION_LINK, std::string(), false); break; case IDC_CONTENT_CONTEXT_LOAD_IMAGE: ExecLoadImage(); break; case IDC_CONTENT_CONTEXT_OPENIMAGENEWTAB: case IDC_CONTENT_CONTEXT_OPENAVNEWTAB: OpenURL(params_.src_url, GetDocumentURL(params_), WindowOpenDisposition::NEW_BACKGROUND_TAB, ui::PAGE_TRANSITION_LINK); break; case IDC_CONTENT_CONTEXT_PLAYPAUSE: ExecPlayPause(); break; case IDC_CONTENT_CONTEXT_MUTE: ExecMute(); break; case IDC_CONTENT_CONTEXT_LOOP: ExecLoop(); break; case IDC_CONTENT_CONTEXT_CONTROLS: ExecControls(); break; case IDC_CONTENT_CONTEXT_ROTATECW: ExecRotateCW(); break; case IDC_CONTENT_CONTEXT_ROTATECCW: ExecRotateCCW(); break; case IDC_BACK: embedder_web_contents_->GetController().GoBack(); break; case IDC_FORWARD: embedder_web_contents_->GetController().GoForward(); break; case IDC_SAVE_PAGE: embedder_web_contents_->OnSavePage(); break; case IDC_SEND_TAB_TO_SELF_SINGLE_TARGET: send_tab_to_self::ShareToSingleTarget( GetBrowser()->tab_strip_model()->GetActiveWebContents()); send_tab_to_self::RecordSendTabToSelfClickResult( send_tab_to_self::kContentMenu, SendTabToSelfClickResult::kClickItem); break; case IDC_CONTENT_LINK_SEND_TAB_TO_SELF_SINGLE_TARGET: send_tab_to_self::ShareToSingleTarget( GetBrowser()->tab_strip_model()->GetActiveWebContents(), params_.link_url); send_tab_to_self::RecordSendTabToSelfClickResult( send_tab_to_self::kLinkMenu, SendTabToSelfClickResult::kClickItem); break; case IDC_CONTENT_CONTEXT_GENERATE_QR_CODE: { auto* web_contents = GetBrowser()->tab_strip_model()->GetActiveWebContents(); auto* bubble_controller = qrcode_generator::QRCodeGeneratorBubbleController::Get(web_contents); NavigationEntry* entry = embedder_web_contents_->GetController().GetLastCommittedEntry(); bubble_controller->ShowBubble(entry->GetURL()); break; } case IDC_RELOAD: chrome::Reload(GetBrowser(), WindowOpenDisposition::CURRENT_TAB); break; case IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP: ExecReloadPackagedApp(); break; case IDC_CONTENT_CONTEXT_RESTART_PACKAGED_APP: ExecRestartPackagedApp(); break; case IDC_PRINT: ExecPrint(); break; case IDC_ROUTE_MEDIA: ExecRouteMedia(); break; case IDC_CONTENT_CONTEXT_EXIT_FULLSCREEN: ExecExitFullscreen(); break; case IDC_VIEW_SOURCE: embedder_web_contents_->GetMainFrame()->ViewSource(); break; case IDC_CONTENT_CONTEXT_INSPECTELEMENT: ExecInspectElement(); break; case IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE: ExecInspectBackgroundPage(); break; case IDC_CONTENT_CONTEXT_TRANSLATE: ExecTranslate(); break; case IDC_CONTENT_CONTEXT_RELOADFRAME: source_web_contents_->ReloadFocusedFrame(); break; case IDC_CONTENT_CONTEXT_VIEWFRAMESOURCE: if (GetRenderFrameHost()) GetRenderFrameHost()->ViewSource(); break; case IDC_CONTENT_CONTEXT_UNDO: source_web_contents_->Undo(); break; case IDC_CONTENT_CONTEXT_REDO: source_web_contents_->Redo(); break; case IDC_CONTENT_CONTEXT_CUT: source_web_contents_->Cut(); break; case IDC_CONTENT_CONTEXT_COPY: source_web_contents_->Copy(); break; case IDC_CONTENT_CONTEXT_PASTE: source_web_contents_->Paste(); break; case IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE: source_web_contents_->PasteAndMatchStyle(); break; case IDC_CONTENT_CONTEXT_DELETE: source_web_contents_->Delete(); break; case IDC_CONTENT_CONTEXT_SELECTALL: source_web_contents_->SelectAll(); break; case IDC_CONTENT_CONTEXT_SEARCHWEBFOR: case IDC_CONTENT_CONTEXT_GOTOURL: OpenURL(selection_navigation_url_, GURL(), ui::DispositionFromEventFlags( event_flags, WindowOpenDisposition::NEW_FOREGROUND_TAB), ui::PAGE_TRANSITION_LINK); break; case IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS: ExecLanguageSettings(event_flags); break; case IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS: ExecProtocolHandlerSettings(event_flags); break; case IDC_CONTENT_CONTEXT_GENERATEPASSWORD: password_manager_util::UserTriggeredManualGenerationFromContextMenu( ChromePasswordManagerClient::FromWebContents(source_web_contents_)); break; case IDC_CONTENT_CONTEXT_SHOWALLSAVEDPASSWORDS: NavigateToManagePasswordsPage( GetBrowser(), password_manager::ManagePasswordsReferrer::kPasswordContextMenu); password_manager::metrics_util::LogContextOfShowAllSavedPasswordsAccepted( password_manager::metrics_util::ShowAllSavedPasswordsContext:: kContextMenu); break; case IDC_CONTENT_CONTEXT_PICTUREINPICTURE: ExecPictureInPicture(); break; case IDC_CONTENT_CONTEXT_EMOJI: { Browser* browser = GetBrowser(); if (browser) { browser->window()->ShowEmojiPanel(); } else { // TODO(https://crbug.com/919167): Ensure this is called in the correct // process. This fails in print preview for PWA windows on Mac. ui::ShowEmojiPanel(); } break; } default: NOTREACHED(); break; } } void RenderViewContextMenu::AddSpellCheckServiceItem(bool is_checked) { AddSpellCheckServiceItem(&menu_model_, is_checked); } void RenderViewContextMenu::AddAccessibilityLabelsServiceItem(bool is_checked) { if (is_checked) { menu_model_.AddCheckItemWithStringId( IDC_CONTENT_CONTEXT_ACCESSIBILITY_LABELS_TOGGLE, IDS_CONTENT_CONTEXT_ACCESSIBILITY_LABELS_MENU_OPTION); } else { // Add the submenu if the whole feature is not enabled. accessibility_labels_submenu_model_.AddItemWithStringId( IDC_CONTENT_CONTEXT_ACCESSIBILITY_LABELS_TOGGLE, IDS_CONTENT_CONTEXT_ACCESSIBILITY_LABELS_SEND); accessibility_labels_submenu_model_.AddItemWithStringId( IDC_CONTENT_CONTEXT_ACCESSIBILITY_LABELS_TOGGLE_ONCE, IDS_CONTENT_CONTEXT_ACCESSIBILITY_LABELS_SEND_ONCE); menu_model_.AddSubMenu( IDC_CONTENT_CONTEXT_ACCESSIBILITY_LABELS, l10n_util::GetStringUTF16( IDS_CONTENT_CONTEXT_ACCESSIBILITY_LABELS_MENU_OPTION), &accessibility_labels_submenu_model_); } } // static void RenderViewContextMenu::RegisterMenuShownCallbackForTesting( base::OnceCallback<void(RenderViewContextMenu*)> cb) { *GetMenuShownCallback() = std::move(cb); } ProtocolHandlerRegistry::ProtocolHandlerList RenderViewContextMenu::GetHandlersForLinkUrl() { ProtocolHandlerRegistry::ProtocolHandlerList handlers = protocol_handler_registry_->GetHandlersFor(params_.link_url.scheme()); std::sort(handlers.begin(), handlers.end()); return handlers; } void RenderViewContextMenu::NotifyMenuShown() { auto* cb = GetMenuShownCallback(); if (!cb->is_null()) std::move(*cb).Run(this); } base::string16 RenderViewContextMenu::PrintableSelectionText() { return gfx::TruncateString(params_.selection_text, kMaxSelectionTextLength, gfx::WORD_BREAK); } void RenderViewContextMenu::EscapeAmpersands(base::string16* text) { base::ReplaceChars(*text, base::ASCIIToUTF16("&"), base::ASCIIToUTF16("&&"), text); } // Controller functions -------------------------------------------------------- bool RenderViewContextMenu::IsReloadEnabled() const { CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(embedder_web_contents_); if (!core_tab_helper) return false; Browser* browser = GetBrowser(); return !browser || browser->CanReloadContents(embedder_web_contents_); } bool RenderViewContextMenu::IsViewSourceEnabled() const { if (!!extensions::MimeHandlerViewGuest::FromWebContents( source_web_contents_)) { return false; } return (params_.media_type != ContextMenuDataMediaType::kPlugin) && embedder_web_contents_->GetController().CanViewSource(); } bool RenderViewContextMenu::IsDevCommandEnabled(int id) const { if (id == IDC_CONTENT_CONTEXT_INSPECTELEMENT || id == IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE) { PrefService* prefs = GetPrefs(browser_context_); if (!prefs->GetBoolean(prefs::kWebKitJavascriptEnabled)) return false; // Don't enable the web inspector if the developer tools are disabled via // the preference dev-tools-disabled. if (!DevToolsWindow::AllowDevToolsFor(GetProfile(), source_web_contents_)) return false; } return true; } bool RenderViewContextMenu::IsTranslateEnabled() const { ChromeTranslateClient* chrome_translate_client = ChromeTranslateClient::FromWebContents(embedder_web_contents_); // If no |chrome_translate_client| attached with this WebContents or we're // viewing in a MimeHandlerViewGuest translate will be disabled. if (!chrome_translate_client || !!extensions::MimeHandlerViewGuest::FromWebContents( source_web_contents_)) { return false; } std::string original_lang = chrome_translate_client->GetLanguageState().original_language(); std::string target_lang = GetTargetLanguage(); // Note that we intentionally enable the menu even if the original and // target languages are identical. This is to give a way to user to // translate a page that might contains text fragments in a different // language. return ((params_.edit_flags & ContextMenuDataEditFlags::kCanTranslate) != 0) && !original_lang.empty() && // Did we receive the page language yet? !chrome_translate_client->GetLanguageState().IsPageTranslated() && // There are some application locales which can't be used as a // target language for translation. In that case GetTargetLanguage() // may return empty. !target_lang.empty() && // Disable on the Instant Extended NTP. !search::IsInstantNTP(embedder_web_contents_); } bool RenderViewContextMenu::IsSaveLinkAsEnabled() const { PrefService* local_state = g_browser_process->local_state(); DCHECK(local_state); // Test if file-selection dialogs are forbidden by policy. if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) return false; return params_.link_url.is_valid() && ProfileIOData::IsHandledProtocol(params_.link_url.scheme()); } bool RenderViewContextMenu::IsSaveImageAsEnabled() const { PrefService* local_state = g_browser_process->local_state(); DCHECK(local_state); // Test if file-selection dialogs are forbidden by policy. if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) return false; return params_.has_image_contents; } bool RenderViewContextMenu::IsSaveAsEnabled() const { PrefService* local_state = g_browser_process->local_state(); DCHECK(local_state); // Test if file-selection dialogs are forbidden by policy. if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) return false; const GURL& url = params_.src_url; bool can_save = (params_.media_flags & WebContextMenuData::kMediaCanSave) && url.is_valid() && ProfileIOData::IsHandledProtocol(url.scheme()); #if BUILDFLAG(ENABLE_PRINT_PREVIEW) // Do not save the preview PDF on the print preview page. can_save = can_save && !(printing::PrintPreviewDialogController::IsPrintPreviewURL(url)); #endif return can_save; } bool RenderViewContextMenu::IsSavePageEnabled() const { CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(embedder_web_contents_); if (!core_tab_helper) return false; Browser* browser = GetBrowser(); if (browser && !browser->CanSaveContents(embedder_web_contents_)) return false; PrefService* local_state = g_browser_process->local_state(); DCHECK(local_state); // Test if file-selection dialogs are forbidden by policy. if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) return false; // We save the last committed entry (which the user is looking at), as // opposed to any pending URL that hasn't committed yet. NavigationEntry* entry = embedder_web_contents_->GetController().GetLastCommittedEntry(); return content::IsSavableURL(entry ? entry->GetURL() : GURL()); } bool RenderViewContextMenu::IsPasteEnabled() const { if (!(params_.edit_flags & ContextMenuDataEditFlags::kCanPaste)) return false; std::vector<base::string16> types; ui::Clipboard::GetForCurrentThread()->ReadAvailableTypes( ui::ClipboardBuffer::kCopyPaste, &types); return !types.empty(); } bool RenderViewContextMenu::IsPasteAndMatchStyleEnabled() const { if (!(params_.edit_flags & ContextMenuDataEditFlags::kCanPaste)) return false; return ui::Clipboard::GetForCurrentThread()->IsFormatAvailable( ui::ClipboardFormatType::GetPlainTextType(), ui::ClipboardBuffer::kCopyPaste); } bool RenderViewContextMenu::IsPrintPreviewEnabled() const { if (params_.media_type != ContextMenuDataMediaType::kNone && !(params_.media_flags & WebContextMenuData::kMediaCanPrint)) { return false; } Browser* browser = GetBrowser(); return browser && chrome::CanPrint(browser); } bool RenderViewContextMenu::IsQRCodeGeneratorEnabled() const { if (!GetBrowser()) return false; NavigationEntry* entry = embedder_web_contents_->GetController().GetLastCommittedEntry(); if (!entry) return false; bool incognito = browser_context_->IsOffTheRecord(); return qrcode_generator::QRCodeGeneratorBubbleController:: IsGeneratorAvailable(entry->GetURL(), incognito); } bool RenderViewContextMenu::IsRouteMediaEnabled() const { if (!media_router::MediaRouterEnabled(browser_context_)) return false; Browser* browser = GetBrowser(); if (!browser) return false; // Disable the command if there is an active modal dialog. // We don't use |source_web_contents_| here because it could be the // WebContents for something that's not the current tab (e.g., WebUI // modal dialog). WebContents* web_contents = browser->tab_strip_model()->GetActiveWebContents(); if (!web_contents) return false; const web_modal::WebContentsModalDialogManager* manager = web_modal::WebContentsModalDialogManager::FromWebContents(web_contents); return !manager || !manager->IsDialogActive(); } bool RenderViewContextMenu::IsOpenLinkOTREnabled() const { if (browser_context_->IsOffTheRecord() || !params_.link_url.is_valid()) return false; if (!IsURLAllowedInIncognito(params_.link_url, browser_context_)) return false; IncognitoModePrefs::Availability incognito_avail = IncognitoModePrefs::GetAvailability(GetPrefs(browser_context_)); return incognito_avail != IncognitoModePrefs::DISABLED; } void RenderViewContextMenu::ExecOpenBookmarkApp() { base::Optional<web_app::AppId> app_id = web_app::FindInstalledAppWithUrlInScope( Profile::FromBrowserContext(browser_context_), params_.link_url); // |app_id| could be nullopt if it has been uninstalled since the user // opened the context menu. if (!app_id) return; apps::AppLaunchParams launch_params( *app_id, apps::mojom::LaunchContainer::kLaunchContainerWindow, WindowOpenDisposition::CURRENT_TAB, apps::mojom::AppLaunchSource::kSourceContextMenu); launch_params.override_url = params_.link_url; apps::AppServiceProxyFactory::GetForProfile(GetProfile()) ->BrowserAppLauncher() .LaunchAppWithParams(launch_params); } void RenderViewContextMenu::ExecProtocolHandler(int event_flags, int handler_index) { ProtocolHandlerRegistry::ProtocolHandlerList handlers = GetHandlersForLinkUrl(); if (handlers.empty()) return; base::RecordAction( UserMetricsAction("RegisterProtocolHandler.ContextMenu_Open")); WindowOpenDisposition disposition = ui::DispositionFromEventFlags( event_flags, WindowOpenDisposition::NEW_FOREGROUND_TAB); OpenURL(handlers[handler_index].TranslateUrl(params_.link_url), GetDocumentURL(params_), disposition, ui::PAGE_TRANSITION_LINK); } void RenderViewContextMenu::ExecOpenLinkInProfile(int profile_index) { DCHECK_GE(profile_index, 0); DCHECK_LE(profile_index, static_cast<int>(profile_link_paths_.size())); base::FilePath profile_path = profile_link_paths_[profile_index]; Profile* profile = g_browser_process->profile_manager()->GetProfileByPath(profile_path); UmaEnumOpenLinkAsUser profile_state; if (chrome::FindLastActiveWithProfile(profile)) { profile_state = OPEN_LINK_AS_USER_ACTIVE_PROFILE_ENUM_ID; } else if (multiple_profiles_open_) { profile_state = OPEN_LINK_AS_USER_INACTIVE_PROFILE_MULTI_PROFILE_SESSION_ENUM_ID; } else { profile_state = OPEN_LINK_AS_USER_INACTIVE_PROFILE_SINGLE_PROFILE_SESSION_ENUM_ID; } UMA_HISTOGRAM_ENUMERATION("RenderViewContextMenu.OpenLinkAsUser", profile_state, OPEN_LINK_AS_USER_LAST_ENUM_ID); profiles::SwitchToProfile( profile_path, false, base::Bind(OnProfileCreated, params_.link_url, CreateReferrer(params_.link_url, params_))); } void RenderViewContextMenu::ExecInspectElement() { base::RecordAction(UserMetricsAction("DevTools_InspectElement")); RenderFrameHost* render_frame_host = GetRenderFrameHost(); if (!render_frame_host) return; DevToolsWindow::InspectElement(render_frame_host, params_.x, params_.y); } void RenderViewContextMenu::ExecInspectBackgroundPage() { const Extension* platform_app = GetExtension(); DCHECK(platform_app); DCHECK(platform_app->is_platform_app()); extensions::devtools_util::InspectBackgroundPage(platform_app, GetProfile()); } void RenderViewContextMenu::ExecSaveLinkAs() { RenderFrameHost* render_frame_host = GetRenderFrameHost(); if (!render_frame_host) return; RecordDownloadSource(DOWNLOAD_INITIATED_BY_CONTEXT_MENU); const GURL& url = params_.link_url; net::NetworkTrafficAnnotationTag traffic_annotation = net::DefineNetworkTrafficAnnotation("render_view_context_menu", R"( semantics { sender: "Save Link As" description: "Saving url to local file." trigger: "The user selects the 'Save link as...' command in the context " "menu." data: "None." destination: WEBSITE } policy { cookies_allowed: YES cookies_store: "user" setting: "This feature cannot be disabled by settings. The request is made " "only if user chooses 'Save link as...' in the context menu." policy_exception_justification: "Not implemented." })"); auto dl_params = std::make_unique<DownloadUrlParameters>( url, render_frame_host->GetProcess()->GetID(), render_frame_host->GetRenderViewHost()->GetRoutingID(), render_frame_host->GetRoutingID(), traffic_annotation); content::Referrer referrer = CreateReferrer(url, params_); dl_params->set_referrer(referrer.url); dl_params->set_referrer_policy( content::Referrer::ReferrerPolicyForUrlRequest(referrer.policy)); dl_params->set_referrer_encoding(params_.frame_charset); dl_params->set_suggested_name(params_.suggested_filename); dl_params->set_prompt(true); dl_params->set_download_source(download::DownloadSource::CONTEXT_MENU); BrowserContext::GetDownloadManager(browser_context_) ->DownloadUrl(std::move(dl_params)); } void RenderViewContextMenu::ExecSaveAs() { bool is_large_data_url = params_.has_image_contents && params_.src_url.is_empty(); if (params_.media_type == ContextMenuDataMediaType::kCanvas || (params_.media_type == ContextMenuDataMediaType::kImage && is_large_data_url)) { RenderFrameHost* frame_host = GetRenderFrameHost(); if (frame_host) frame_host->SaveImageAt(params_.x, params_.y); } else { RecordDownloadSource(DOWNLOAD_INITIATED_BY_CONTEXT_MENU); const GURL& url = params_.src_url; content::Referrer referrer = CreateReferrer(url, params_); std::string headers; source_web_contents_->SaveFrameWithHeaders(url, referrer, headers, params_.suggested_filename); } } void RenderViewContextMenu::ExecExitFullscreen() { Browser* browser = GetBrowser(); if (!browser) { NOTREACHED(); return; } browser->exclusive_access_manager()->ExitExclusiveAccess(); } void RenderViewContextMenu::ExecCopyLinkText() { ui::ScopedClipboardWriter scw(ui::ClipboardBuffer::kCopyPaste); scw.WriteText(params_.link_text); } void RenderViewContextMenu::ExecCopyImageAt() { RenderFrameHost* frame_host = GetRenderFrameHost(); if (frame_host) frame_host->CopyImageAt(params_.x, params_.y); } void RenderViewContextMenu::ExecSearchWebForImage() { CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(source_web_contents_); if (!core_tab_helper) return; RenderFrameHost* render_frame_host = GetRenderFrameHost(); if (!render_frame_host) return; core_tab_helper->SearchByImageInNewTab(render_frame_host, params().src_url); } void RenderViewContextMenu::ExecLoadImage() { RenderFrameHost* render_frame_host = GetRenderFrameHost(); if (!render_frame_host) return; mojo::AssociatedRemote<chrome::mojom::ChromeRenderFrame> chrome_render_frame; render_frame_host->GetRemoteAssociatedInterfaces()->GetInterface( &chrome_render_frame); chrome_render_frame->RequestReloadImageForContextNode(); } void RenderViewContextMenu::ExecPlayPause() { bool play = !!(params_.media_flags & WebContextMenuData::kMediaPaused); if (play) base::RecordAction(UserMetricsAction("MediaContextMenu_Play")); else base::RecordAction(UserMetricsAction("MediaContextMenu_Pause")); MediaPlayerActionAt(gfx::Point(params_.x, params_.y), blink::mojom::MediaPlayerAction( blink::mojom::MediaPlayerActionType::kPlay, play)); } void RenderViewContextMenu::ExecMute() { bool mute = !(params_.media_flags & WebContextMenuData::kMediaMuted); if (mute) base::RecordAction(UserMetricsAction("MediaContextMenu_Mute")); else base::RecordAction(UserMetricsAction("MediaContextMenu_Unmute")); MediaPlayerActionAt(gfx::Point(params_.x, params_.y), blink::mojom::MediaPlayerAction( blink::mojom::MediaPlayerActionType::kMute, mute)); } void RenderViewContextMenu::ExecLoop() { base::RecordAction(UserMetricsAction("MediaContextMenu_Loop")); MediaPlayerActionAt(gfx::Point(params_.x, params_.y), blink::mojom::MediaPlayerAction( blink::mojom::MediaPlayerActionType::kLoop, !IsCommandIdChecked(IDC_CONTENT_CONTEXT_LOOP))); } void RenderViewContextMenu::ExecControls() { base::RecordAction(UserMetricsAction("MediaContextMenu_Controls")); MediaPlayerActionAt(gfx::Point(params_.x, params_.y), blink::mojom::MediaPlayerAction( blink::mojom::MediaPlayerActionType::kControls, !IsCommandIdChecked(IDC_CONTENT_CONTEXT_CONTROLS))); } void RenderViewContextMenu::ExecRotateCW() { base::RecordAction(UserMetricsAction("PluginContextMenu_RotateClockwise")); PluginActionAt(gfx::Point(params_.x, params_.y), blink::mojom::PluginActionType::kRotate90Clockwise); } void RenderViewContextMenu::ExecRotateCCW() { base::RecordAction( UserMetricsAction("PluginContextMenu_RotateCounterclockwise")); PluginActionAt(gfx::Point(params_.x, params_.y), blink::mojom::PluginActionType::kRotate90Counterclockwise); } void RenderViewContextMenu::ExecReloadPackagedApp() { const Extension* platform_app = GetExtension(); DCHECK(platform_app); DCHECK(platform_app->is_platform_app()); extensions::ExtensionSystem::Get(browser_context_) ->extension_service() ->ReloadExtension(platform_app->id()); } void RenderViewContextMenu::ExecRestartPackagedApp() { const Extension* platform_app = GetExtension(); DCHECK(platform_app); DCHECK(platform_app->is_platform_app()); apps::AppLoadService::Get(GetProfile()) ->RestartApplication(platform_app->id()); } void RenderViewContextMenu::ExecPrint() { #if BUILDFLAG(ENABLE_PRINTING) if (params_.media_type != ContextMenuDataMediaType::kNone) { RenderFrameHost* rfh = GetRenderFrameHost(); if (rfh) { mojo::AssociatedRemote<printing::mojom::PrintRenderFrame> remote; rfh->GetRemoteAssociatedInterfaces()->GetInterface(&remote); remote->PrintNodeUnderContextMenu(); } return; } printing::StartPrint( source_web_contents_, mojo::NullAssociatedRemote(), GetPrefs(browser_context_)->GetBoolean(prefs::kPrintPreviewDisabled), !params_.selection_text.empty()); #endif // BUILDFLAG(ENABLE_PRINTING) } void RenderViewContextMenu::ExecRouteMedia() { if (!media_router::MediaRouterEnabled(browser_context_)) return; media_router::MediaRouterDialogController* dialog_controller = media_router::MediaRouterDialogController::GetOrCreateForWebContents( embedder_web_contents_); if (!dialog_controller) return; dialog_controller->ShowMediaRouterDialog( media_router::MediaRouterDialogOpenOrigin::CONTEXTUAL_MENU); media_router::MediaRouterMetrics::RecordMediaRouterDialogOrigin( media_router::MediaRouterDialogOpenOrigin::CONTEXTUAL_MENU); } void RenderViewContextMenu::ExecTranslate() { // A translation might have been triggered by the time the menu got // selected, do nothing in that case. ChromeTranslateClient* chrome_translate_client = ChromeTranslateClient::FromWebContents(embedder_web_contents_); if (!chrome_translate_client || chrome_translate_client->GetLanguageState().IsPageTranslated() || chrome_translate_client->GetLanguageState().translation_pending()) { return; } std::string original_lang = chrome_translate_client->GetLanguageState().original_language(); std::string target_lang = GetTargetLanguage(); // Since the user decided to translate for that language and site, clears // any preferences for not translating them. std::unique_ptr<translate::TranslatePrefs> prefs( ChromeTranslateClient::CreateTranslatePrefs( GetPrefs(browser_context_))); prefs->UnblockLanguage(original_lang); prefs->RemoveSiteFromBlacklist(params_.page_url.HostNoBrackets()); translate::TranslateManager* manager = chrome_translate_client->GetTranslateManager(); DCHECK(manager); manager->TranslatePage(original_lang, target_lang, true); } void RenderViewContextMenu::ExecLanguageSettings(int event_flags) { WindowOpenDisposition disposition = ui::DispositionFromEventFlags( event_flags, WindowOpenDisposition::NEW_FOREGROUND_TAB); GURL url = chrome::GetSettingsUrl(chrome::kLanguageOptionsSubPage); OpenURL(url, GURL(), disposition, ui::PAGE_TRANSITION_LINK); } void RenderViewContextMenu::ExecProtocolHandlerSettings(int event_flags) { base::RecordAction( UserMetricsAction("RegisterProtocolHandler.ContextMenu_Settings")); WindowOpenDisposition disposition = ui::DispositionFromEventFlags( event_flags, WindowOpenDisposition::NEW_FOREGROUND_TAB); GURL url = chrome::GetSettingsUrl(chrome::kHandlerSettingsSubPage); OpenURL(url, GURL(), disposition, ui::PAGE_TRANSITION_LINK); } void RenderViewContextMenu::ExecPictureInPicture() { if (!base::FeatureList::IsEnabled(media::kPictureInPicture)) return; bool picture_in_picture_active = IsCommandIdChecked(IDC_CONTENT_CONTEXT_PICTUREINPICTURE); if (picture_in_picture_active) { base::RecordAction( UserMetricsAction("MediaContextMenu_ExitPictureInPicture")); } else { base::RecordAction( UserMetricsAction("MediaContextMenu_EnterPictureInPicture")); } MediaPlayerActionAt( gfx::Point(params_.x, params_.y), blink::mojom::MediaPlayerAction( blink::mojom::MediaPlayerActionType::kPictureInPicture, !picture_in_picture_active)); } void RenderViewContextMenu::MediaPlayerActionAt( const gfx::Point& location, const blink::mojom::MediaPlayerAction& action) { RenderFrameHost* frame_host = GetRenderFrameHost(); if (frame_host) frame_host->ExecuteMediaPlayerActionAtLocation(location, action); } void RenderViewContextMenu::PluginActionAt( const gfx::Point& location, blink::mojom::PluginActionType plugin_action) { source_web_contents_->GetRenderViewHost()->ExecutePluginActionAtLocation( location, plugin_action); } Browser* RenderViewContextMenu::GetBrowser() const { return chrome::FindBrowserWithWebContents(embedder_web_contents_); }
[ "youngsoo.choi@lge.com" ]
youngsoo.choi@lge.com
89d65a5e698cd5a59d53b8f51e645fe84b26bfa2
37456d03c7dfa4720fde33c239b370a05c5b58e4
/fherenhite_to_calcious.cpp
7e5a3810861a2f6bc5cecbb3496b8d17e2e3b95b
[]
no_license
mohibul2000/MY_PROJECTS
d3fc1b9afc8fa1c2d58e9f391a0b8eb16be62d5f
dddb15956e49be51b74ba2f56e1fc8c5f22c79f6
refs/heads/master
2023-07-10T03:17:16.254476
2021-08-08T03:44:55
2021-08-08T03:44:55
271,186,255
0
0
null
null
null
null
UTF-8
C++
false
false
310
cpp
#include<stdio.h> #include<math.h> int main() { int c,f; printf("enter the celcius temp:..."); scanf("%d",&c); f=(9*c+160)/5; printf("changing temparature is:%d",f); printf("enter the fher temp:..."); scanf("%d",&f); c=(5*f-160)/9; printf("changing temparature is:%d",c); return 0; }
[ "noreply@github.com" ]
noreply@github.com
dee563ad7c20e8cd590123e9df66bda650d56c18
31aa0bd1eaad4cd452d0e2c367d8905f8ed44ba3
/algorithms/numberOfStepsToReduceANumberToZero/numberOfStepsToReduceANumberToZero.cpp
173dfb58c01b401c363312a0a7ac320defe2726e
[]
no_license
Sean-Lan/leetcode
0bb0bfaf3a63d483794a0e5213a983db3bbe6ef6
1583c1b81c30140df78d188c327413a351d8c0af
refs/heads/master
2021-04-19T02:49:33.572569
2021-01-04T01:40:06
2021-01-04T01:40:06
33,580,092
3
0
null
null
null
null
UTF-8
C++
false
false
1,660
cpp
/** * * Sean * 2020-03-30 * * https://leetcode.com/problems/number-of-steps-to-reduce-a-number-to-zero/ * * Given a non-negative integer num, return the number of steps to reduce it to zero. If the current * number is even, you have to divide it by 2, otherwise, you have to subtract 1 from it. * * Example 1: * * Input: num = 14 * Output: 6 * Explanation: * Step 1) 14 is even; divide by 2 and obtain 7. * Step 2) 7 is odd; subtract 1 and obtain 6. * Step 3) 6 is even; divide by 2 and obtain 3. * Step 4) 3 is odd; subtract 1 and obtain 2. * Step 5) 2 is even; divide by 2 and obtain 1. * Step 6) 1 is odd; subtract 1 and obtain 0. * Example 2: * * Input: num = 8 * Output: 4 * Explanation: * Step 1) 8 is even; divide by 2 and obtain 4. * Step 2) 4 is even; divide by 2 and obtain 2. * Step 3) 2 is even; divide by 2 and obtain 1. * Step 4) 1 is odd; subtract 1 and obtain 0. * Example 3: * * Input: num = 123 * Output: 12 * * Constraints: * * 0 <= num <= 10^6 * */ #include <iostream> using namespace std; // take the number in binary. // if the current digit is 1, we need 2 steps to remove it. // 1. -1 // 2. /2 (right shift 1 bit) // if the current digit is 0, we need 1 step to remove it. // 1. /2 (right shift 1 bit) class Solution { public: int numberOfSteps (int num) { if (num == 0) return 0; int cnt = 0; while (num) { if (num & 1) cnt += 2; else ++cnt; num >>= 1; } -- cnt; return cnt; } }; int main() { Solution solution; int cnt = solution.numberOfSteps(123); cout << cnt << endl; return 0; }
[ "xiang.lan@airbnb.com" ]
xiang.lan@airbnb.com
99f96787e8ae0bdbee079ada0c3907bc43eff224
d85b1f3ce9a3c24ba158ca4a51ea902d152ef7b9
/testcases/CWE762_Mismatched_Memory_Management_Routines/s03/CWE762_Mismatched_Memory_Management_Routines__delete_int64_t_calloc_61b.cpp
20fdd05c96be1321d78ffc9e25646394063cac52
[]
no_license
arichardson/juliet-test-suite-c
cb71a729716c6aa8f4b987752272b66b1916fdaa
e2e8cf80cd7d52f824e9a938bbb3aa658d23d6c9
refs/heads/master
2022-12-10T12:05:51.179384
2022-11-17T15:41:30
2022-12-01T15:25:16
179,281,349
34
34
null
2022-12-01T15:25:18
2019-04-03T12:03:21
null
UTF-8
C++
false
false
1,625
cpp
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE762_Mismatched_Memory_Management_Routines__delete_int64_t_calloc_61b.cpp Label Definition File: CWE762_Mismatched_Memory_Management_Routines__delete.label.xml Template File: sources-sinks-61b.tmpl.cpp */ /* * @description * CWE: 762 Mismatched Memory Management Routines * BadSource: calloc Allocate data using calloc() * GoodSource: Allocate data using new * Sinks: * GoodSink: Deallocate data using free() * BadSink : Deallocate data using delete * Flow Variant: 61 Data flow: data returned from one function to another in different source files * * */ #include "std_testcase.h" namespace CWE762_Mismatched_Memory_Management_Routines__delete_int64_t_calloc_61 { #ifndef OMITBAD int64_t * badSource(int64_t * data) { /* POTENTIAL FLAW: Allocate memory with a function that requires free() to free the memory */ data = (int64_t *)calloc(100, sizeof(int64_t)); if (data == NULL) {exit(-1);} return data; } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B() uses the GoodSource with the BadSink */ int64_t * goodG2BSource(int64_t * data) { /* FIX: Allocate memory from the heap using new */ data = new int64_t; return data; } /* goodB2G() uses the BadSource with the GoodSink */ int64_t * goodB2GSource(int64_t * data) { /* POTENTIAL FLAW: Allocate memory with a function that requires free() to free the memory */ data = (int64_t *)calloc(100, sizeof(int64_t)); if (data == NULL) {exit(-1);} return data; } #endif /* OMITGOOD */ } /* close namespace */
[ "Alexander.Richardson@cl.cam.ac.uk" ]
Alexander.Richardson@cl.cam.ac.uk
ccee03298db69d3b692f8b36bc4921d4b5321346
69d7f930b7c19adb564d3f41e584c1d74cf80bd4
/src/test/rpc_tests.cpp
89a822dba3c23130ca7e1f7a0771453756dfbd43
[ "MIT" ]
permissive
markus901/goacoin
763ffacd8898e4f096f8cc18945b8b9657b1f0f7
0f7723dadbaab15d37b9012bc567bb44b891c147
refs/heads/master
2021-05-14T16:17:07.164520
2017-12-16T13:32:52
2017-12-16T13:32:52
null
0
0
null
null
null
null
UTF-8
C++
false
false
16,692
cpp
// Copyright (c) 2012-2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "rpcserver.h" #include "rpcclient.h" #include "base58.h" #include "netbase.h" #include "test/test_goacoin.h" #include <boost/algorithm/string.hpp> #include <boost/test/unit_test.hpp> #include <univalue.h> using namespace std; UniValue createArgs(int nRequired, const char* address1=NULL, const char* address2=NULL) { UniValue result(UniValue::VARR); result.push_back(nRequired); UniValue addresses(UniValue::VARR); if (address1) addresses.push_back(address1); if (address2) addresses.push_back(address2); result.push_back(addresses); return result; } UniValue CallRPC(string args) { vector<string> vArgs; boost::split(vArgs, args, boost::is_any_of(" \t")); string strMethod = vArgs[0]; vArgs.erase(vArgs.begin()); UniValue params = RPCConvertValues(strMethod, vArgs); rpcfn_type method = tableRPC[strMethod]->actor; try { UniValue result = (*method)(params, false); return result; } catch (const UniValue& objError) { throw runtime_error(find_value(objError, "message").get_str()); } } BOOST_FIXTURE_TEST_SUITE(rpc_tests, TestingSetup) BOOST_AUTO_TEST_CASE(rpc_rawparams) { // Test raw transaction API argument handling UniValue r; BOOST_CHECK_THROW(CallRPC("getrawtransaction"), runtime_error); BOOST_CHECK_THROW(CallRPC("getrawtransaction not_hex"), runtime_error); BOOST_CHECK_THROW(CallRPC("getrawtransaction a3b807410df0b60fcb9736768df5823938b2f838694939ba45f3c0a1bff150ed not_int"), runtime_error); BOOST_CHECK_THROW(CallRPC("createrawtransaction"), runtime_error); BOOST_CHECK_THROW(CallRPC("createrawtransaction null null"), runtime_error); BOOST_CHECK_THROW(CallRPC("createrawtransaction not_array"), runtime_error); BOOST_CHECK_THROW(CallRPC("createrawtransaction [] []"), runtime_error); BOOST_CHECK_THROW(CallRPC("createrawtransaction {} {}"), runtime_error); BOOST_CHECK_NO_THROW(CallRPC("createrawtransaction [] {}")); BOOST_CHECK_THROW(CallRPC("createrawtransaction [] {} extra"), runtime_error); BOOST_CHECK_THROW(CallRPC("decoderawtransaction"), runtime_error); BOOST_CHECK_THROW(CallRPC("decoderawtransaction null"), runtime_error); BOOST_CHECK_THROW(CallRPC("decoderawtransaction DEADBEEF"), runtime_error); string rawtx = "0100000001a15d57094aa7a21a28cb20b59aab8fc7d1149a3bdbcddba9c622e4f5f6a99ece010000006c493046022100f93bb0e7d8db7bd46e40132d1f8242026e045f03a0efe71bbb8e3f475e970d790221009337cd7f1f929f00cc6ff01f03729b069a7c21b59b1736ddfee5db5946c5da8c0121033b9b137ee87d5a812d6f506efdd37f0affa7ffc310711c06c7f3e097c9447c52ffffffff0100e1f505000000001976a9140389035a9225b3839e2bbf32d826a1e222031fd888ac00000000"; BOOST_CHECK_NO_THROW(r = CallRPC(string("decoderawtransaction ")+rawtx)); BOOST_CHECK_EQUAL(find_value(r.get_obj(), "size").get_int(), 193); BOOST_CHECK_EQUAL(find_value(r.get_obj(), "version").get_int(), 1); BOOST_CHECK_EQUAL(find_value(r.get_obj(), "locktime").get_int(), 0); BOOST_CHECK_THROW(r = CallRPC(string("decoderawtransaction ")+rawtx+" extra"), runtime_error); BOOST_CHECK_THROW(CallRPC("signrawtransaction"), runtime_error); BOOST_CHECK_THROW(CallRPC("signrawtransaction null"), runtime_error); BOOST_CHECK_THROW(CallRPC("signrawtransaction ff00"), runtime_error); BOOST_CHECK_NO_THROW(CallRPC(string("signrawtransaction ")+rawtx)); BOOST_CHECK_NO_THROW(CallRPC(string("signrawtransaction ")+rawtx+" null null NONE|ANYONECANPAY")); BOOST_CHECK_NO_THROW(CallRPC(string("signrawtransaction ")+rawtx+" [] [] NONE|ANYONECANPAY")); BOOST_CHECK_THROW(CallRPC(string("signrawtransaction ")+rawtx+" null null badenum"), runtime_error); // Only check failure cases for sendrawtransaction, there's no network to send to... BOOST_CHECK_THROW(CallRPC("sendrawtransaction"), runtime_error); BOOST_CHECK_THROW(CallRPC("sendrawtransaction null"), runtime_error); BOOST_CHECK_THROW(CallRPC("sendrawtransaction DEADBEEF"), runtime_error); BOOST_CHECK_THROW(CallRPC(string("sendrawtransaction ")+rawtx+" extra"), runtime_error); } BOOST_AUTO_TEST_CASE(rpc_rawsign) { UniValue r; // input is a 1-of-2 multisig (so is output): string prevout = "[{\"txid\":\"b4cc287e58f87cdae59417329f710f3ecd75a4ee1d2872b7248f50977c8493f3\"," "\"vout\":1,\"scriptPubKey\":\"a914b10c9df5f7edf436c697f02f1efdba4cf399615187\"," "\"redeemScript\":\"512103debedc17b3df2badbcdd86d5feb4562b86fe182e5998abd8bcd4f122c6155b1b21027e940bb73ab8732bfdf7f9216ecefca5b94d6df834e77e108f68e66f126044c052ae\"}]"; r = CallRPC(string("createrawtransaction ")+prevout+" "+ "{\"7iYoULd4BAqRsRt1UbD5qqna88JvKRU3SL\":11}"); string notsigned = r.get_str(); string privkey1 = "\"XEwTRsCX3CiWSQf8YmKMTeb84KyTbibkUv9mDTZHQ5MwuKG2ZzES\""; string privkey2 = "\"XDmZ7LjGd94Q81eUBjb2h6uV5Y14s7fmeXWEGYabfBJP8RVpprBu\""; r = CallRPC(string("signrawtransaction ")+notsigned+" "+prevout+" "+"[]"); BOOST_CHECK(find_value(r.get_obj(), "complete").get_bool() == false); r = CallRPC(string("signrawtransaction ")+notsigned+" "+prevout+" "+"["+privkey1+","+privkey2+"]"); BOOST_CHECK(find_value(r.get_obj(), "complete").get_bool() == true); } BOOST_AUTO_TEST_CASE(rpc_createraw_op_return) { BOOST_CHECK_NO_THROW(CallRPC("createrawtransaction [{\"txid\":\"a3b807410df0b60fcb9736768df5823938b2f838694939ba45f3c0a1bff150ed\",\"vout\":0}] {\"data\":\"68656c6c6f776f726c64\"}")); // Allow more than one data transaction output BOOST_CHECK_NO_THROW(CallRPC("createrawtransaction [{\"txid\":\"a3b807410df0b60fcb9736768df5823938b2f838694939ba45f3c0a1bff150ed\",\"vout\":0}] {\"data\":\"68656c6c6f776f726c64\",\"data\":\"68656c6c6f776f726c64\"}")); // Key not "data" (bad address) BOOST_CHECK_THROW(CallRPC("createrawtransaction [{\"txid\":\"a3b807410df0b60fcb9736768df5823938b2f838694939ba45f3c0a1bff150ed\",\"vout\":0}] {\"somedata\":\"68656c6c6f776f726c64\"}"), runtime_error); // Bad hex encoding of data output BOOST_CHECK_THROW(CallRPC("createrawtransaction [{\"txid\":\"a3b807410df0b60fcb9736768df5823938b2f838694939ba45f3c0a1bff150ed\",\"vout\":0}] {\"data\":\"12345\"}"), runtime_error); BOOST_CHECK_THROW(CallRPC("createrawtransaction [{\"txid\":\"a3b807410df0b60fcb9736768df5823938b2f838694939ba45f3c0a1bff150ed\",\"vout\":0}] {\"data\":\"12345g\"}"), runtime_error); // Data 81 bytes long BOOST_CHECK_NO_THROW(CallRPC("createrawtransaction [{\"txid\":\"a3b807410df0b60fcb9736768df5823938b2f838694939ba45f3c0a1bff150ed\",\"vout\":0}] {\"data\":\"010203040506070809101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081\"}")); } BOOST_AUTO_TEST_CASE(rpc_format_monetary_values) { BOOST_CHECK(ValueFromAmount(0LL).write() == "0.00000000"); BOOST_CHECK(ValueFromAmount(1LL).write() == "0.00000001"); BOOST_CHECK(ValueFromAmount(17622195LL).write() == "0.17622195"); BOOST_CHECK(ValueFromAmount(50000000LL).write() == "0.50000000"); BOOST_CHECK(ValueFromAmount(89898989LL).write() == "0.89898989"); BOOST_CHECK(ValueFromAmount(100000000LL).write() == "1.00000000"); BOOST_CHECK(ValueFromAmount(2099999999999990LL).write() == "20999999.99999990"); BOOST_CHECK(ValueFromAmount(2099999999999999LL).write() == "20999999.99999999"); BOOST_CHECK_EQUAL(ValueFromAmount(0).write(), "0.00000000"); BOOST_CHECK_EQUAL(ValueFromAmount((COIN/10000)*123456789).write(), "12345.67890000"); BOOST_CHECK_EQUAL(ValueFromAmount(-COIN).write(), "-1.00000000"); BOOST_CHECK_EQUAL(ValueFromAmount(-COIN/10).write(), "-0.10000000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN*100000000).write(), "100000000.00000000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN*10000000).write(), "10000000.00000000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN*1000000).write(), "1000000.00000000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN*100000).write(), "100000.00000000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN*10000).write(), "10000.00000000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN*1000).write(), "1000.00000000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN*100).write(), "100.00000000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN*10).write(), "10.00000000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN).write(), "1.00000000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN/10).write(), "0.10000000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN/100).write(), "0.01000000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN/1000).write(), "0.00100000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN/10000).write(), "0.00010000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN/100000).write(), "0.00001000"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN/1000000).write(), "0.00000100"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN/10000000).write(), "0.00000010"); BOOST_CHECK_EQUAL(ValueFromAmount(COIN/100000000).write(), "0.00000001"); } static UniValue ValueFromString(const std::string &str) { UniValue value; BOOST_CHECK(value.setNumStr(str)); return value; } BOOST_AUTO_TEST_CASE(rpc_parse_monetary_values) { BOOST_CHECK_THROW(AmountFromValue(ValueFromString("-0.00000001")), UniValue); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0")), 0LL); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.00000000")), 0LL); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.00000001")), 1LL); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.17622195")), 17622195LL); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.5")), 50000000LL); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.50000000")), 50000000LL); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.89898989")), 89898989LL); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("1.00000000")), 100000000LL); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("20999999.9999999")), 2099999999999990LL); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("20999999.99999999")), 2099999999999999LL); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("1e-8")), COIN/100000000); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.1e-7")), COIN/100000000); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.01e-6")), COIN/100000000); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.0000000000000000000000000000000000000000000000000000000000000000000000000001e+68")), COIN/100000000); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("10000000000000000000000000000000000000000000000000000000000000000e-64")), COIN); BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000e64")), COIN); BOOST_CHECK_THROW(AmountFromValue(ValueFromString("1e-9")), UniValue); //should fail BOOST_CHECK_THROW(AmountFromValue(ValueFromString("0.000000019")), UniValue); //should fail BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.00000001000000")), 1LL); //should pass, cut trailing 0 BOOST_CHECK_THROW(AmountFromValue(ValueFromString("19e-9")), UniValue); //should fail BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.19e-6")), 19); //should pass, leading 0 is present BOOST_CHECK_THROW(AmountFromValue(ValueFromString("92233720368.54775808")), UniValue); //overflow error BOOST_CHECK_THROW(AmountFromValue(ValueFromString("1e+11")), UniValue); //overflow error BOOST_CHECK_THROW(AmountFromValue(ValueFromString("1e11")), UniValue); //overflow error signless BOOST_CHECK_THROW(AmountFromValue(ValueFromString("93e+9")), UniValue); //overflow error } BOOST_AUTO_TEST_CASE(json_parse_errors) { // Valid BOOST_CHECK_EQUAL(ParseNonRFCJSONValue("1.0").get_real(), 1.0); // Valid, with leading or trailing whitespace BOOST_CHECK_EQUAL(ParseNonRFCJSONValue(" 1.0").get_real(), 1.0); BOOST_CHECK_EQUAL(ParseNonRFCJSONValue("1.0 ").get_real(), 1.0); BOOST_CHECK_THROW(AmountFromValue(ParseNonRFCJSONValue(".19e-6")), std::runtime_error); //should fail, missing leading 0, therefore invalid JSON BOOST_CHECK_EQUAL(AmountFromValue(ParseNonRFCJSONValue("0.00000000000000000000000000000000000001e+30 ")), 1); // Invalid, initial garbage BOOST_CHECK_THROW(ParseNonRFCJSONValue("[1.0"), std::runtime_error); BOOST_CHECK_THROW(ParseNonRFCJSONValue("a1.0"), std::runtime_error); // Invalid, trailing garbage BOOST_CHECK_THROW(ParseNonRFCJSONValue("1.0sds"), std::runtime_error); BOOST_CHECK_THROW(ParseNonRFCJSONValue("1.0]"), std::runtime_error); // BTC addresses should fail parsing BOOST_CHECK_THROW(ParseNonRFCJSONValue("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"), std::runtime_error); BOOST_CHECK_THROW(ParseNonRFCJSONValue("3J98t1WpEZ73CNmQviecrnyiWrnqRhWNL"), std::runtime_error); } BOOST_AUTO_TEST_CASE(rpc_ban) { BOOST_CHECK_NO_THROW(CallRPC(string("clearbanned"))); UniValue r; BOOST_CHECK_NO_THROW(r = CallRPC(string("setban 127.0.0.0 add"))); BOOST_CHECK_THROW(r = CallRPC(string("setban 127.0.0.0:8334")), runtime_error); //portnumber for setban not allowed BOOST_CHECK_NO_THROW(r = CallRPC(string("listbanned"))); UniValue ar = r.get_array(); UniValue o1 = ar[0].get_obj(); UniValue adr = find_value(o1, "address"); BOOST_CHECK_EQUAL(adr.get_str(), "127.0.0.0/32"); BOOST_CHECK_NO_THROW(CallRPC(string("setban 127.0.0.0 remove")));; BOOST_CHECK_NO_THROW(r = CallRPC(string("listbanned"))); ar = r.get_array(); BOOST_CHECK_EQUAL(ar.size(), 0); BOOST_CHECK_NO_THROW(r = CallRPC(string("setban 127.0.0.0/24 add 1607731200 true"))); BOOST_CHECK_NO_THROW(r = CallRPC(string("listbanned"))); ar = r.get_array(); o1 = ar[0].get_obj(); adr = find_value(o1, "address"); UniValue banned_until = find_value(o1, "banned_until"); BOOST_CHECK_EQUAL(adr.get_str(), "127.0.0.0/24"); BOOST_CHECK_EQUAL(banned_until.get_int64(), 1607731200); // absolute time check BOOST_CHECK_NO_THROW(CallRPC(string("clearbanned"))); BOOST_CHECK_NO_THROW(r = CallRPC(string("setban 127.0.0.0/24 add 200"))); BOOST_CHECK_NO_THROW(r = CallRPC(string("listbanned"))); ar = r.get_array(); o1 = ar[0].get_obj(); adr = find_value(o1, "address"); banned_until = find_value(o1, "banned_until"); BOOST_CHECK_EQUAL(adr.get_str(), "127.0.0.0/24"); int64_t now = GetTime(); BOOST_CHECK(banned_until.get_int64() > now); BOOST_CHECK(banned_until.get_int64()-now <= 200); // must throw an exception because 127.0.0.1 is in already banned suubnet range BOOST_CHECK_THROW(r = CallRPC(string("setban 127.0.0.1 add")), runtime_error); BOOST_CHECK_NO_THROW(CallRPC(string("setban 127.0.0.0/24 remove")));; BOOST_CHECK_NO_THROW(r = CallRPC(string("listbanned"))); ar = r.get_array(); BOOST_CHECK_EQUAL(ar.size(), 0); BOOST_CHECK_NO_THROW(r = CallRPC(string("setban 127.0.0.0/255.255.0.0 add"))); BOOST_CHECK_THROW(r = CallRPC(string("setban 127.0.1.1 add")), runtime_error); BOOST_CHECK_NO_THROW(CallRPC(string("clearbanned"))); BOOST_CHECK_NO_THROW(r = CallRPC(string("listbanned"))); ar = r.get_array(); BOOST_CHECK_EQUAL(ar.size(), 0); BOOST_CHECK_THROW(r = CallRPC(string("setban test add")), runtime_error); //invalid IP //IPv6 tests BOOST_CHECK_NO_THROW(r = CallRPC(string("setban FE80:0000:0000:0000:0202:B3FF:FE1E:8329 add"))); BOOST_CHECK_NO_THROW(r = CallRPC(string("listbanned"))); ar = r.get_array(); o1 = ar[0].get_obj(); adr = find_value(o1, "address"); BOOST_CHECK_EQUAL(adr.get_str(), "fe80::202:b3ff:fe1e:8329/128"); BOOST_CHECK_NO_THROW(CallRPC(string("clearbanned"))); BOOST_CHECK_NO_THROW(r = CallRPC(string("setban 2001:db8::/ffff:fffc:0:0:0:0:0:0 add"))); BOOST_CHECK_NO_THROW(r = CallRPC(string("listbanned"))); ar = r.get_array(); o1 = ar[0].get_obj(); adr = find_value(o1, "address"); BOOST_CHECK_EQUAL(adr.get_str(), "2001:db8::/30"); BOOST_CHECK_NO_THROW(CallRPC(string("clearbanned"))); BOOST_CHECK_NO_THROW(r = CallRPC(string("setban 2001:4d48:ac57:400:cacf:e9ff:fe1d:9c63/128 add"))); BOOST_CHECK_NO_THROW(r = CallRPC(string("listbanned"))); ar = r.get_array(); o1 = ar[0].get_obj(); adr = find_value(o1, "address"); BOOST_CHECK_EQUAL(adr.get_str(), "2001:4d48:ac57:400:cacf:e9ff:fe1d:9c63/128"); } BOOST_AUTO_TEST_SUITE_END()
[ "goacoincore@gmail.com" ]
goacoincore@gmail.com
be0e5d4c295965d691bee6026e61daa92f6e823f
fb1fc28ddce9e0092ecdce00340bbbc3f66b6ec5
/d03/ex02/includes/FragTrap.hpp
0bcf29144b600284e5d546f7a2b909e55573fe6d
[]
no_license
anstadnik/CPP_pool
a20b020433ea317938b3291b313444ca0303b6a3
0af45b506764fbadf8856b3562f66f8553d21fd7
refs/heads/master
2023-09-05T05:29:34.038747
2018-04-17T08:49:33
2018-04-17T08:49:33
428,276,607
0
0
null
null
null
null
UTF-8
C++
false
false
287
hpp
#ifndef FRAGTRAP_HPP #define FRAGTRAP_HPP #include "ClapTrap.hpp" #include <string> class FragTrap: public ClapTrap { public: FragTrap(); FragTrap(std::string name); FragTrap(const FragTrap &src); ~FragTrap(); int vaulthunter_dot_exe(std::string const & target); }; #endif
[ "astadnik@student.unit.ua" ]
astadnik@student.unit.ua
20cee0fcf765ef2e8fce476861f45259180af569
e2eae3d94491b6c401aea5b7eb1a3d55efa6d650
/Camera.cpp
5ee91b8150666e02021603b9d2f8408f029cde43
[]
no_license
jayong93/3DGameProgramming
2df4cd865efbc8b78898d5dd48b6928eaf8fbd27
e68f75ecc8a212991c26e8eedaff27b1a2b76bc6
refs/heads/master
2020-12-25T09:47:10.164070
2016-06-20T12:53:40
2016-06-20T12:53:40
60,511,547
0
0
null
null
null
null
UTF-8
C++
false
false
7,288
cpp
#include "stdafx.h" #include "Player.h" #include "Camera.h" CCamera::CCamera(CCamera* cam) : player(nullptr), cbCamera{ nullptr } { if (cam) { position = cam->GetPosition(); right = cam->GetRightVector(); look = cam->GetLookVector(); up = cam->GetUpVector(); pitch = cam->GetPitch(); yaw = cam->GetYaw(); roll = cam->GetRoll(); mtxProjection = cam->GetProjectionMatrix(); mtxView = cam->GetViewMatrix(); viewport = cam->GetViewport(); offset = cam->GetOffset(); timeLag = cam->GetTimeLag(); player = cam->GetPlayer(); cbCamera = cam->GetCameraConstantBuffer(); if (cbCamera) cbCamera->AddRef(); } else { position = D3DXVECTOR3{ 0.f,0.f,0.f }; right = D3DXVECTOR3{ 1.f,0.f,0.f }; up = D3DXVECTOR3{ 0.f,1.f,0.f }; look = D3DXVECTOR3{ 0.f,0.f,1.f }; pitch = 0.f; yaw = 0.f; roll = 0.f; offset = D3DXVECTOR3{ 0.f,0.f,0.f }; timeLag = 0.f; player = nullptr; cbCamera = nullptr; D3DXMatrixIdentity(&mtxView); D3DXMatrixIdentity(&mtxProjection); mode = CameraMode::NONE; } } CCamera::~CCamera() { if (cbCamera) cbCamera->Release(); } void CCamera::SetViewport(ID3D11DeviceContext * deviceContext, DWORD xStart, DWORD yStart, DWORD width, DWORD height, float minZ, float maxZ) { viewport.TopLeftX = (float)xStart; viewport.TopLeftY = (float)yStart; viewport.Width = (float)width; viewport.Height = (float)height; viewport.MinDepth = minZ; viewport.MaxDepth = maxZ; deviceContext->RSSetViewports(1, &viewport); } void CCamera::CreateViewMatrix() { D3DXMatrixLookAtLH(&mtxView, &position, &look, &up); } void CCamera::RecreateViewMatrix() { D3DXVec3Normalize(&look, &look); D3DXVec3Cross(&right, &up, &look); D3DXVec3Normalize(&right, &right); D3DXVec3Cross(&up, &look, &right); D3DXVec3Normalize(&up, &up); mtxView._11 = right.x; mtxView._12 = up.x; mtxView._13 = look.x; mtxView._21 = right.y; mtxView._22 = up.y; mtxView._23 = look.y; mtxView._31 = right.z; mtxView._32 = up.z; mtxView._33 = look.z; mtxView._41 = D3DXVec3Dot(&position, &right); mtxView._42 = D3DXVec3Dot(&position, &up); mtxView._43 = D3DXVec3Dot(&position, &look); } void CCamera::CreateProjectionMatrix(float nearDist, float farDist, float aspect, float fov) { D3DXMatrixPerspectiveFovLH(&mtxProjection, (float)D3DXToRadian(fov), aspect, nearDist, farDist); } void CCamera::CreateShaderVariable(ID3D11Device * device) { D3D11_BUFFER_DESC bDesc; ZeroMemory(&bDesc, sizeof(D3D11_BUFFER_DESC)); bDesc.Usage = D3D11_USAGE_DYNAMIC; bDesc.ByteWidth = sizeof(VS_CB_CAMERA); bDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; bDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; device->CreateBuffer(&bDesc, nullptr, &cbCamera); } void CCamera::UpdateShaderVariable(ID3D11DeviceContext * deviceContext) { D3D11_MAPPED_SUBRESOURCE mapRes; deviceContext->Map(cbCamera, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapRes); VS_CB_CAMERA* viewProjection = (VS_CB_CAMERA*)mapRes.pData; D3DXMatrixTranspose(&viewProjection->mtxView, &mtxView); D3DXMatrixTranspose(&viewProjection->mtxProjection, &mtxProjection); deviceContext->Unmap(cbCamera, 0); deviceContext->VSSetConstantBuffers(VS_SLOT_CAMERA, 1, &cbCamera); } CSpaceShipCamera::CSpaceShipCamera(CCamera * cam) : CCamera(cam) { mode = CameraMode::SPACESHIP; } void CSpaceShipCamera::Rotate(float pitch, float yaw, float roll) { D3DXMATRIX rm; if (player&&pitch != 0.f) { D3DXMatrixRotationAxis(&rm, &player->GetRightVector(), (float)D3DXToRadian(pitch)); D3DXVec3TransformNormal(&right, &right, &rm); D3DXVec3TransformNormal(&up, &up, &rm); D3DXVec3TransformNormal(&look, &look, &rm); position -= player->GetPosition(); D3DXVec3TransformCoord(&position, &position, &rm); position += player->GetPosition(); } if (player && (yaw != 0.f)) { D3DXMatrixRotationAxis(&rm, &player->GetUpVector(), (float)D3DXToRadian(yaw)); D3DXVec3TransformNormal(&right, &right, &rm); D3DXVec3TransformNormal(&up, &up, &rm); D3DXVec3TransformNormal(&look, &look, &rm); position -= player->GetPosition(); D3DXVec3TransformCoord(&position, &position, &rm); position += player->GetPosition(); } if (player && (roll != 0.f)) { D3DXMatrixRotationAxis(&rm, &player->GetLookVector(), (float)D3DXToRadian(roll)); D3DXVec3TransformNormal(&right, &right, &rm); D3DXVec3TransformNormal(&up, &up, &rm); D3DXVec3TransformNormal(&look, &look, &rm); position -= player->GetPosition(); D3DXVec3TransformCoord(&position, &position, &rm); position += player->GetPosition(); } } CFirstPersonCamera::CFirstPersonCamera(CCamera * cam) : CCamera{ cam } { mode = CameraMode::FIRST_PERSON; if (cam) { if (cam->GetMode() == CameraMode::SPACESHIP) { up = D3DXVECTOR3(0.f, 1.f, 0.f); right.y = 0.f; look.y = 0.f; D3DXVec3Normalize(&right, &right); D3DXVec3Normalize(&look, &look); } } } void CFirstPersonCamera::Rotate(float pitch, float yaw, float roll) { D3DXMATRIX rm; if (pitch != 0.f) { D3DXMatrixRotationAxis(&rm, &player->GetRightVector(), (float)D3DXToRadian(pitch)); D3DXVec3TransformNormal(&right, &right, &rm); D3DXVec3TransformNormal(&up, &up, &rm); D3DXVec3TransformNormal(&look, &look, &rm); } if (yaw != 0.f) { D3DXMatrixRotationAxis(&rm, &player->GetUpVector(), (float)D3DXToRadian(yaw)); D3DXVec3TransformNormal(&right, &right, &rm); D3DXVec3TransformNormal(&up, &up, &rm); D3DXVec3TransformNormal(&look, &look, &rm); } if (roll != 0.f) { D3DXMatrixRotationAxis(&rm, &player->GetLookVector(), (float)D3DXToRadian(roll)); position -= player->GetPosition(); D3DXVec3TransformCoord(&position, &position, &rm); position += player->GetPosition(); D3DXVec3TransformNormal(&right, &right, &rm); D3DXVec3TransformNormal(&up, &up, &rm); D3DXVec3TransformNormal(&look, &look, &rm); } } CThirdPersonCamera::CThirdPersonCamera(CCamera * cam) : CCamera{ cam } { mode = CameraMode::THIRD_PERSON; if (cam) { if (cam->GetMode() == CameraMode::SPACESHIP) { up = D3DXVECTOR3{ 0.f,1.f,0.f }; right.y = 0.f; look.y = 0.f; D3DXVec3Normalize(&right, &right); D3DXVec3Normalize(&look, &look); } } } void CThirdPersonCamera::Update(D3DXVECTOR3 & lookAt, float timeScale) { if (player) { D3DXMATRIX rm; D3DXMatrixIdentity(&rm); D3DXVECTOR3 vr = player->GetRightVector(); D3DXVECTOR3 vu = player->GetUpVector(); D3DXVECTOR3 vl = player->GetLookVector(); rm._11 = vr.x; rm._21 = vu.x; rm._31 = vl.x; rm._12 = vr.y; rm._22 = vu.y; rm._32 = vl.y; rm._13 = vr.z; rm._23 = vu.z; rm._33 = vl.z; D3DXVECTOR3 os; D3DXVec3TransformCoord(&os, &offset, &rm); D3DXVECTOR3 pos = player->GetPosition() + os; D3DXVECTOR3 direction = pos - position; float length = D3DXVec3Length(&direction); direction /= length; float timeLagScale = timeLag ? timeScale * (1.f / timeLag) : 1.f; float distance = length * timeLagScale; if (distance > length || length < 0.01f) distance = length; if (distance > 0) { position += direction * distance; SetLookAt(lookAt); } } } void CThirdPersonCamera::SetLookAt(D3DXVECTOR3 & lookAt) { D3DXMATRIX mla; D3DXMatrixLookAtLH(&mla, &position, &lookAt, &player->GetUpVector()); right = D3DXVECTOR3{ mla._11,mla._21,mla._31 }; up = D3DXVECTOR3{ mla._12,mla._22,mla._32 }; look = D3DXVECTOR3{ mla._13,mla._23,mla._33 }; }
[ "JaeYong Choi" ]
JaeYong Choi
02647ce7cd0c30bc9770e1b19b902d8a3f2a3329
c8dfc743c17411d30bbde1309505dd33baaddf7f
/fabrik/inc/fabrik/scene_manager.h
889b9bcf92c41867f370142beba64089ae6a4313
[]
no_license
OneManMonkeySquad/AWE
2ba8d51c4a85f2bf868c895dc5898e980b13ff65
e8b67f608e46956323a483d04de88de7e27047ff
refs/heads/master
2021-12-23T16:23:24.826779
2021-10-30T13:19:35
2021-10-30T13:19:35
237,494,665
2
2
null
null
null
null
UTF-8
C++
false
false
192
h
#pragma once #include "scene.h" class scene_manager { public: ~scene_manager(); scene& create_scene(); scene& get_first_scene(); private: std::list<std::unique_ptr<scene>> _scenes; };
[ "Oliver.Weitzel@auvesy.de" ]
Oliver.Weitzel@auvesy.de
10707e593f38bfdb204a18104871db9a9f1aeda5
e15138f99b5cb3ba82931c4b8db560d06916d1d6
/Finger/FingerDlg.cpp
0811f717df6fc6af7760b2685e9a9aa6927c20c1
[]
no_license
xiaosonghao/fingerprint
5b8042c782c36cc5fba39e311d67ad278b933023
dc113da935f29226b578d4b038fcc322ac553b43
refs/heads/master
2022-12-20T05:43:53.421085
2020-09-12T19:09:59
2020-09-12T19:09:59
294,771,915
0
0
null
null
null
null
UTF-8
C++
false
false
84,921
cpp
#define _CRT_SECURE_NO_DEPRECATE #pragma warning(disable:4996) //#define _CRT_SECURE_NO_WARNINGS // FingerDlg.cpp: 实现文件 // #include "pch.h" #include "Resource.h" #include "framework.h" #include "Finger.h" #include "FingerDlg.h" #include "afxdialogex.h" #include<io.h>//for filelength() #include <iomanip> #include<fstream> using namespace std; #define STEP_IMG_1 "temp\\Step1_Source.bmp" #define STEP_TXT_1 "temp\\Step1_Source.txt" #define STEP_TXT_2 "temp\\Step2_MidFilter.txt" #define STEP_IMG_2 "temp\\Step2_MidFilter.bmp" #define STEP_TXT_3 "temp\\Step3_Normalize.txt" #define STEP_IMG_3 "temp\\Step3_Normalize.bmp" #define STEP_IMG_4 "temp\\Step4_Direction.bmp" #define STEP_TXT_4 "temp\\Step4_Direction.txt" #define STEP_TXT_5 "temp\\Step5_Frequency.txt" #define STEP_IMG_5 "temp\\Step5_Frequency.bmp" #define STEP_TXT_6 "temp\\Step6_Mask.txt" #define STEP_IMG_6 "temp\\Step6_Mask.bmp" #define STEP_TXT_7 "temp\\Step7_GaborEnhance.txt" #define STEP_IMG_7 "temp\\Step7_GaborEnhance.bmp" #define STEP_TXT_8 "temp\\Step8_Binary.txt" #define STEP_IMG_8 "temp\\Step8_Binary.bmp" #define STEP_TXT_9 "temp\\Step9_Thinning.txt" #define STEP_IMG_9 "temp\\Step9_Thinning.bmp" #define STEP_TXT_10 "temp\\Step10_MinuExtract.txt" #define STEP_IMG_10 "temp\\Step10_MinuExtract.bmp" #define STEP_TXT_11 "temp\\Step11_MinuFilter.txt" #define STEP_IMG_11 "temp\\Step11_MinuFilter.bmp" #define STEP_IMG_11_MDL "temp\\Step11_MinuFilter_MDL.mdl" #define STEP_IMG_12 "temp\\Step12_Result.bmp" #ifdef _DEBUG #define new DEBUG_NEW #endif // CFingerDlg 对话框 CFingerDlg::CFingerDlg(CWnd* pParent /*=nullptr*/) : CDialogEx(IDD_FINGER_DIALOG, pParent) , m_name(_T("")) { m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CFingerDlg::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); DDX_Control(pDX, IDC_STATIC_INFO, m_staticInfo); DDX_Control(pDX, IDC_STATIC_IMG_1, m_picCtrl1); DDX_Control(pDX, IDC_STATIC_IMG_2, m_picCtrl2); DDX_Text(pDX, IDC_EDIT_NAME, m_name); DDX_Control(pDX, IDC_ZKFPENGX, m_zkfpEng); DDX_Control(pDX, IDC_STATIC_IMG_3, m_picCtrl3); DDX_Control(pDX, IDC_STATIC_IMG_4, m_picCtrl4); DDX_Control(pDX, IDC_STATIC_IMG_5, m_picCtrl5); DDX_Control(pDX, IDC_STATIC_IMG_6, m_picCtrl6); DDX_Control(pDX, IDC_STATIC_IMG_7, m_picCtrl7); DDX_Control(pDX, IDC_STATIC_IMG_8, m_picCtrl8); DDX_Control(pDX, IDC_STATIC_IMG_9, m_picCtrl9); DDX_Control(pDX, IDC_STATIC_IMG_10, m_picCtrl10); DDX_Control(pDX, IDC_STATIC_IMG_11, m_picCtrl11); DDX_Control(pDX, IDC_STATIC_IMG_12, m_picCtrl12); } BEGIN_MESSAGE_MAP(CFingerDlg, CDialogEx) ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDC_BTN_EXIT, &CFingerDlg::OnBnClickedBtnExit) ON_BN_CLICKED(IDC_BTN_STEP_1, &CFingerDlg::OnBnClickedBtnStep1) ON_BN_CLICKED(IDC_BTN_DATABASE, &CFingerDlg::OnBnClickedBtnDatabase) ON_BN_CLICKED(IDC_BTN_STEP_12A, &CFingerDlg::OnBnClickedBtnStep12a) ON_BN_CLICKED(IDC_BTN_STEP_12B, &CFingerDlg::OnBnClickedBtnStep12b) ON_BN_CLICKED(IDC_BTN_STEP_12B2, &CFingerDlg::OnBnClickedBtnStep12b2) END_MESSAGE_MAP() //BEGIN_EVENTSINK_MAP(CFingerDlg,CDialog) // ON_EVENT(CFingerDlg,IDC_ZKFPENGX,8,OnImageReceivedZkfpengx,VTS_PBOOL) //END_EVENTSINK_MAP() // CFingerDlg 消息处理程序 BOOL CFingerDlg::OnInitDialog() { CDialogEx::OnInitDialog(); // 设置此对话框的图标。 当应用程序主窗口不是对话框时,框架将自动 // 执行此操作 SetIcon(m_hIcon, TRUE); // 设置大图标 SetIcon(m_hIcon, FALSE); // 设置小图标 // TODO: 在此添加额外的初始化代码 InitDatabase();//创建并初始化指纹库 return TRUE; // 除非将焦点设置到控件,否则返回 TRUE } // 如果向对话框添加最小化按钮,则需要下面的代码 // 来绘制该图标。 对于使用文档/视图模型的 MFC 应用程序, // 这将由框架自动完成。 void CFingerDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // 用于绘制的设备上下文 SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0); // 使图标在工作区矩形中居中 int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // 绘制图标 dc.DrawIcon(x, y, m_hIcon); } else { CDialogEx::OnPaint(); } } //当用户拖动最小化窗口时系统调用此函数取得光标 //显示。 HCURSOR CFingerDlg::OnQueryDragIcon() { return static_cast<HCURSOR>(m_hIcon); } //void CFingerDlg::OnImageReceivedZkfpengx(BOOL FAR* AImageValid) //{ // HDC hdc = this->GetDC()->m_hDC;//获得显示设备上下文环境的句柄 // int x = 160;//图像绘制区左上角横坐标 // int y = 80;//图像绘制区左上角纵坐标 // int width = m_zkfpEng.get_ImageWidth();//图像绘制区宽度 // int height = m_zkfpEng.get_ImageHeight();//图像绘制区高度 // m_zkfpEng.PrintImageAt(int(hdc), x, y, width, height);//绘制图像 //} wchar_t *ToWideChar(char *str)//多字节字符串转换为Unicode宽字符串 { int num = MultiByteToWideChar(0, 0, str, -1, NULL, 0); wchar_t *wideStr = new wchar_t[num]; MultiByteToWideChar(0, 0, str, -1, wideStr, num); return wideStr; } //参数:picCtrl(图像控件),filename(图像文件路径) int ShowImageInCtrl(CStatic &picCtrl, char *filename) { //载入图像 CImage image; HRESULT hResult = image.Load(ToWideChar(filename)); //获得图像参数 int width = image.GetWidth();//图像宽度 int height = image.GetHeight();//图像高度 //设置显示区域 CRect rect;//定义矩形对象 picCtrl.GetClientRect(&rect);//获得pictrue控件所在的矩形区域 CDC *pDc = picCtrl.GetWindowDC();//获得pictrue控件的设备环境句柄 SetStretchBltMode(pDc->m_hDC, STRETCH_HALFTONE);//设置位图拉伸模式 //显示图像 image.StretchBlt(pDc->m_hDC, rect, SRCCOPY);//将图像画到Picture控件表示的矩形区域 //更新控件显示 picCtrl.Invalidate(false); //释放变量空间 image.Destroy(); picCtrl.ReleaseDC(pDc);//释放picture控件的设备环境句柄 return 0; } int ReadBMPImgFilePara(char *fileName, int &width, int &height, int &depth) { //载入图像 CImage image; HRESULT hResult = image.Load(ToWideChar(fileName)); if (FAILED(hResult) || image.IsNull())//图像损坏或文件不存在等因素均可导致载入失败 { return -1; } //获得图像参数 width = image.GetWidth();//获得以像素为单位的图像宽度 height = image.GetHeight();//获得以像素为单位的图像高度 depth = image.GetBPP();//获得以bit为单位的图像深度(每个像素的位数) if (depth != 8)//目前系统仅支持8位位图,其他类型位图暂不支持 { return -2; } //释放变量空间 image.Destroy(); return 0; } int ReadBMPImgFileData(char *fileName, unsigned char *data) { //载入图像 CImage image; HRESULT hResult = image.Load(ToWideChar(fileName)); if (FAILED(hResult) || image.IsNull())//图像损坏或文件不存在等因素均可导致载入失败 { return -1; } //获得图像参数 int width = image.GetWidth();//获得以像素为单位的图像宽度 int height = image.GetHeight();//获得以像素为单位的图像高度 int depth = image.GetBPP();//获得以bit为单位的图像深度(每个像素的位数) if (depth != 8)//目前系统仅支持8位位图,其他类型位图暂不支持 { return -2; } //初始化结果数组 memset(data, 0, width*height); //读取图像数据 int pitch = image.GetPitch();//每行行首像素的地址偏移量 unsigned char* pData1 = (unsigned char*)image.GetBits();//图像位图数据区地址 unsigned char* pData2 = data; unsigned char gray = 0; unsigned char *pRow1, *pRow2, *pPix1, *pPix2; for (int y = 0; y < height; y++)//逐行扫描 { pRow1 = pData1 + pitch * y; pRow2 = pData2 + width * y; for (int x = 0; x < width; x++)//逐列扫描 { //获得源图像素灰度值 pPix1 = pRow1 + x; gray = *pPix1; //保存到结果数组 pPix2 = pRow2 + x; *pPix2 = gray; }//end for(x) }//end for(y) //在遍历图像像素时,使用的是从图像位图数据区中根据地址偏移量直接读取像素值的方法 //释放变量空间 image.Destroy(); return 0; } //保存位图数据到文本文件 //dstFile(目标文件),data(无符号字符型数据数组),width(图像宽度),height(图像高度) int SaveDataToTextFile(char *dstFile, unsigned char *data, int width, int height) { //打开目标文件 ofstream fout(dstFile, ios::out);//使用覆盖写入方法 if (!fout)//or if(fout.fail()) { return -1; } //按指定格式向文件写入数据 int space = 5;//每个无符号字符型数据均用5个字符位等宽存储 for (int i = 0; i < height*width; i++)//遍历数组 { fout << setw(space) << int(data[i]);//等宽写入数据 if (i%width == (width - 1))//行尾 { fout << endl;//换行 } } //关闭文件 fout.close(); return 0; } //dstFile(目标文件),data(浮点型数据数组),width(图像宽度),height(图像高度) int SaveDataToTextFile(char *dstFile, float *data, int width, int height) { //打开目标文件 ofstream fout(dstFile, ios::out);//使用覆盖写入方法 if (!fout)//or if(fout.fail()) { return -1; } //按指定格式向文件写入数据 int preci = 6;//每个浮点型数据均保留6个小数位 int space = 16;//每个浮点型数据均用16个字符位等宽存储 fout.precision(preci); for (int i = 0; i < height*width; i++)//遍历数组 { fout << " " << setw(space) << data[i];//等宽写入数据 if (i%width == (width - 1))//行尾 { fout << endl;//换行 } } //关闭文件 fout.close(); return 0; } //载入图像单步测试 //info(返回操作结果状态,成功时返回图像参数信息,失败时返回错误提示信息) int Step1_LoadBmpImage(char *info) { CString strFile; char filename[MAX_PATH] = { 0 }; CFileDialog dlgFile(TRUE, NULL, NULL, OFN_HIDEREADONLY, _T("bmp Files (*.bmp)|*.bmp|All Files (*.*)|*.*||"), NULL); if (dlgFile.DoModal() == IDOK)//如果用户在文件对话框中点击了“确定”按钮 { strFile = dlgFile.GetPathName(); int num = WideCharToMultiByte(0, 0, strFile, -1, NULL, 0, NULL, false); char* chStr = new char[num]; WideCharToMultiByte(0, 0, strFile, -1, chStr, num, NULL, false); strcpy(filename, chStr); } //复制图像 CopyFile(ToWideChar(filename), ToWideChar(STEP_IMG_1), false); //读取图像参数并检测有效性 int iWidth, iHeight, iDepth; int flag = ReadBMPImgFilePara(filename, iWidth, iHeight, iDepth); if (flag != 0) { sprintf(info, "图像加载失败."); return -1; } //读取图像数据 unsigned char *data = new unsigned char[iWidth*iHeight]; flag = ReadBMPImgFileData(filename, data); if (flag != 0) { sprintf(info, "图像数据读取失败."); delete[] data;//释放内存 return -2; } //保存数据(TXT文件) flag = SaveDataToTextFile(STEP_TXT_1, data, iWidth, iHeight); if (flag != 0) { sprintf(info, "数据保存失败."); delete[] data;//释放内存 return -3; } //返回图像参数信息//sprintf把字符串的内容赋给info sprintf(info, "源图[%s],宽度[%d],高度[%d],深度[%d b]", filename, iWidth, iHeight, iDepth); //释放内存 delete[] data; return 0; } void InitDatabase()//创建并初始化指纹库 { _mkdir(TEMP_DIR);//创建临时文件夹 _mkdir(DB_DIR);//创建指纹库文件夹 InitFile(DB_INDEX_TXT);//创建索引文件 } void InitFile(char *filename)//创建并初始化文件 { FILE *index = fopen(filename, "w");//若文件不存在则创建,若已存在则清空其内容 fclose(index);//关闭文件 } //参数:info(返回指纹库统计信息,用于系统界面显示) void GetDatabaseInfo(char *info)//获取指纹库统计信息 { //遍历指纹库 int pNo = 0;//指纹序号 char name[MAX_PATH] = { 0 };//登记人姓名 char srcFile[MAX_PATH] = { 0 };//指纹图像文件 char mdlFile[MAX_PATH] = { 0 };//指纹特征文件 FILE *index = fopen(DB_INDEX_TXT, "r");//打开索引文件 while (!feof(index)) { //fscanf把字符串中的值赋给对应的变量 fscanf(index, "%d %s %s %s\n", &pNo, srcFile, mdlFile, name); } fclose(index);//关闭文件 //统计指纹库信息//sprintf把字符串的内容赋给info sprintf(info, "当前指纹库中共有%d条记录.", pNo); } /*本项目使用文本文件保存所有的中间结果数据.每项单步处理功能执行时,都是先从上步操作结果 数据对应的文本文件中读取位图数据,进行本步处理之后,再将本步的结果数据存入本步对应的 文本文件,作为后续步骤的输入数据.*/ //从文本文件读取无符号字符类型的图像位图数据 //srcFile(源文件),data(无符号字符型数据数组),iWidth(图像宽度),iHeight(图像高度) int ReadDataFromTextFile(char *srcFile, unsigned char *data, int iWidth, int iHeight) { //打开源文件 ifstream fin(srcFile, ios::in); if (!fin)//or if(fin.fail()) { return -1; } //读取数据 int d = 0; for (int i = 0; i < iHeight*iWidth; i++) { fin >> d; data[i] = (unsigned char)d; } //关闭文件 fin.close(); return 0; } //从文本文件读取浮点数类型的其他数据 //srcFile(源文件),data(浮点型数据数组),iWidth(图像宽度),iHeight(图像高度) int ReadDataFromTextFile(char *srcFile, float *data, int iWidth, int iHeight) { //打开源文件 ifstream fin(srcFile, ios::in); if (!fin)//or if(fin.fail()) { return -1; } //读取数据 for (int i = 0; i < iHeight*iWidth; i++) { fin >> data[i]; } //关闭文件 fin.close(); return 0; } //使用冒泡法对数组进行升序排序 //参数:data(数组),dsize(数组长度) void Sort(unsigned char *data, int dsize) { unsigned char temp = 0; for (int i = 0; i < dsize; i++) { for (int j = dsize - 1; j > i; j--) { if (data[j] < data[j - 1])//升序排序 { temp = data[j]; data[j] = data[j - 1]; data[j - 1] = temp; } } } } //参数:ucImg(源图数据),ucDstImg(结果图像数据),iWidth(图像宽度),iHeight(图像高度) int MidFilter(unsigned char *ucImg, unsigned char *ucDstImg, int iWidth, int iHeight) { //Step1:结果图像数据初始化 memset(ucDstImg, 0, iWidth*iHeight); //Step2:中心区域滤波(使用3*3邻域) unsigned char *pUp, *pDown, *pImg;//用来确定3*3邻域的3个图像数据指针(下文简称"邻域指针") unsigned char x[9];//3*3邻域图像数据数组 for (int i = 1; i < iHeight - 1; i++)//遍历第2行到倒数第2行 { //初始化邻域指针 pUp = ucImg + (i - 1)*iWidth; pImg = ucImg + i * iWidth; pDown = ucImg + (i + 1)*iWidth; for (int j = 1; j < iWidth - 1; j++)//遍历第2列到倒数第2列 { //移动邻域指针 pUp++; pImg++; pDown++; //获取3*3邻域数据 x[0] = *(pUp - 1); x[1] = *(pImg - 1); x[2] = *(pDown - 1); x[3] = *pUp; x[4] = *pImg; x[5] = *pDown; x[6] = *(pUp + 1); x[7] = *(pImg + 1); x[8] = *(pDown + 1); //数组排序 Sort(x, 9); //结果图像数据取邻域中值 *(ucDstImg + i * iWidth + j) = x[4]; } } //Step3:第1行和最后1行滤波(使用2*3邻域) //第1行 pDown = ucImg + iWidth;//邻域指针初始化 for (int j = 1; j < iWidth - 1; j++)//第1行遍历第2列到倒数第2列 { //获取2*3邻域数据 x[0] = *(ucImg + j - 1); x[1] = *(ucImg + j); x[2] = *(ucImg + j + 1); x[3] = *(pDown + j - 1); x[4] = *(pDown + j); x[5] = *(pDown + j + 1); //数组排序 Sort(x,6); //结果取中值 *(ucDstImg + j) = x[3]; } //最后1行(倒数第1行) pUp = ucImg + iWidth * (iHeight - 2);//邻域指针初始化 pDown = ucImg + iWidth * (iHeight - 1);//邻域指针初始化 for (int j = 1; j < iWidth - 1; j++)//最后1行遍历第2列到倒数第2列 { //获取2*3邻域数据 x[0] = *(pDown + j - 1); x[1] = *(pDown + j); x[2] = *(pDown + j + 1); x[3] = *(pUp + j - 1); x[4] = *(pUp + j); x[5] = *(pUp + j + 1); //数组排序 Sort(x,6); //结果取中值 *(ucDstImg + iWidth * (iHeight - 1) + j) = x[3]; } //Step4:4个角点滤波(使用2*2邻域) //左上角点 x[0] = *(ucImg);//获取2*2邻域数据 x[1] = *(ucImg+1); x[2] = *(ucImg+iWidth); x[3] = *(ucImg + iWidth + 1); Sort(x, 4);//数组排序 *(ucDstImg) = x[2];//结果取中值 //右上角点 x[0] = *(ucImg + iWidth - 1);//获取2*2邻域数据 x[1] = *(ucImg + iWidth - 2); x[2] = *(ucImg + 2 * iWidth - 1); x[3] = *(ucImg + 2 * iWidth - 2); Sort(x, 4);//数组排序 *(ucDstImg + iWidth - 1) = x[2];//结果取中值 //左下角点 x[0] = *(ucImg + (iHeight - 1)*iWidth);//获取2*2邻域数据 x[1] = *(ucImg + (iHeight - 2)*iWidth); x[2] = *(ucImg + (iHeight - 1)*iWidth + 1); x[3] = *(ucImg + (iHeight - 2)*iWidth + 1); Sort(x, 4);//数组排序 *(ucDstImg + (iHeight - 1)*iWidth) = x[2];//结果取中值 //右下角点 x[0] = *(ucImg + (iHeight - 0)*iWidth - 1);//获取2*2邻域数据 x[1] = *(ucImg + (iHeight - 1)*iWidth - 1); x[2] = *(ucImg + (iHeight - 0)*iWidth - 2); x[3] = *(ucImg + (iHeight - 1)*iWidth - 2); Sort(x, 4);//数组排序 *(ucDstImg + (iHeight - 0)*iWidth - 1) = x[2];//结果取中值 return 0; } /*本项目使用图像文件来保存所有中间结果, 用于在系统界面上直观展示与查看各步操作结果的处理效果.*/ //将位图数据写入BMP图像文件 //dstFileName(目标文件名),pusImgData(待保存数据数组) int WriteBMPImgFile(char *dstFileName, unsigned char **pusImgData) { //打开文件 FILE *fp = fopen(dstFileName, "r+b"); if (!fp) { return -1; } //读取图像参数信息(用于定位数据区以写入数据,见参考资料中"BMP图像文件组成") int imgType, iWidth, iHeight;//图像深度/宽度/高度 int iStartPos = 0;//位图数据区起始地址 fseek(fp, 10L, SEEK_SET); fread((char*)(&iStartPos), 4, 1, fp);//获取位图数据区起始地址(以字节为单位) fseek(fp, 18L, SEEK_SET); fread((char*)(&iWidth), 4, 1, fp);//获取图像宽度(以像素为单位) fread((char*)(&iHeight), 4, 1, fp);//获取图像高度(以像素为单位) unsigned short temp; fseek(fp, 28L, SEEK_SET); fread((char*)(&temp), 2, 1, fp);//获取图像深度(每个像素的位数,以位为单位) imgType = temp; if (imgType != 8)//目前仅支持8位BMP位图图像 { return -2; } //向数据区写入数据 unsigned char *usImgData = *pusImgData;//待保存数据数组地址 int iWidthInFile = 0;//文件中每行像素宽度/长度(以字节为单位) if (iWidth % 4 > 0) { iWidthInFile = iWidth - iWidth % 4 + 4; } else { iWidthInFile = iWidth; } for (int i = iHeight - 1; i >= 0; i--)//从最后一行到第一行倒序存储 { fseek(fp, iStartPos, SEEK_SET);//定位行首地址 fwrite((usImgData + i * iWidth), 1, iWidth, fp);//写入一行数据 iStartPos += iWidthInFile;//调整行首地址 } //关闭文件 fclose(fp); return 0; } //保存数据到BMP图像文件 //srcFile(源文件名),dstFile(目标文件名),data(待保存数据数组) int SaveDataToImageFile(char *srcFile, char *dstFile, unsigned char *data) { //文件复制 CopyFile(ToWideChar(srcFile), ToWideChar(dstFile), false); //写入数据 WriteBMPImgFile(dstFile, &data); return 0; } //保存数据到BMP图像文件 //srcFile(源文件名),dstFile(目标文件名),data(待保存数据数组),scale(转换比例) int SaveDataToImageFile(char *srcFile, char *dstFile, float *data, float scale) { //读取图像参数 int iWidth, iHeight, iDepth;//图像宽度/高度/深度 ReadBMPImgFilePara(srcFile, iWidth, iHeight, iDepth); //文件复制 CopyFile(ToWideChar(srcFile), ToWideChar(dstFile), false); //数据转换 unsigned char *tmpData = new unsigned char[iWidth*iHeight]; for (int i = 0; i<int(iWidth*iHeight); i++) { tmpData[i] = unsigned char((scale*data[i])); } //写入数据 WriteBMPImgFile(dstFile, &tmpData); //释放内存空间 delete[] tmpData; return 0; } //中值滤波单步测试 //参数:info(返回操作成功或失败提示信息) int Step2_MidFilter(char *info) { //设置输入输出文件名 char srcTxtFile[MAX_PATH] = { STEP_TXT_1 };//源数据文件名 char srcImgFile[MAX_PATH] = { STEP_IMG_1 };//源图文件名 char dstTxtFile[MAX_PATH] = { STEP_TXT_2 };//结果数据文件名 char dstImgFile[MAX_PATH] = { STEP_IMG_2 };//结果图文件名 //读取图像参数 int iWidth, iHeight, iDepth;//图像宽度/高度/深度 ReadBMPImgFilePara(srcImgFile, iWidth, iHeight, iDepth); //读取源数据 unsigned char *image1 = new unsigned char[iWidth*iHeight]; ReadDataFromTextFile(srcTxtFile, image1, iWidth, iHeight); //中值滤波 unsigned char *image2 = new unsigned char[iWidth*iHeight]; MidFilter(image1, image2, iWidth, iHeight); //保存结果数据(TXT文件) SaveDataToTextFile(dstTxtFile, image2, iWidth, iHeight); //保存结果图像(BMP文件,仅用于显示) SaveDataToImageFile(srcImgFile, dstImgFile, image2); //释放内存空间 delete[] image1; delete[] image2; //返回操作成败状态 sprintf(info, "完成中值滤波."); return 0; } //直方图均衡化//https://blog.csdn.net/qq_15971883/article/details/88699218 //ucImg(源图数据),ucNormImg(结果图数据),iWidth(图像宽度),iHeight(图像高度) int HistoNormalize(unsigned char *ucImg, unsigned char *ucNormImg, int iWidth, int iHeight) { //构建源图灰度直方图 unsigned int Histogram[256]; memset(Histogram, 0, 256 * sizeof(int)); for (int i = 0; i < iHeight; i++) { for (int j = 0; j < iWidth; j++) { Histogram[ucImg[i*iWidth + j]]++; } } //计算源图的灰度均值和方差 double dMean = 0; for (int i = 1; i < 255; i++) { dMean += i * Histogram[i]; } dMean = int(dMean / (iWidth*iHeight)); double dSigma = 0; for (int i = 0; i < 255; i++) { dSigma += Histogram[i] * (i - dMean)*(i - dMean); } dSigma /= (iWidth*iHeight); dSigma = sqrt(dSigma); //对各像素进行均衡化操作 double dMean0 = 128, dSigma0 = 128;//预设灰度均值和方差(此处均设128) double dCoeff = dSigma0 / dSigma;//转换系数 for (int i = 0; i < iHeight; i++) { for (int j = 0; j < iWidth; j++) { double dVal = ucImg[i*iWidth + j]; dVal = dMean0 + dCoeff * (dVal - dMean0); if (dVal < 0) { dVal = 0; } else if (dVal > 255) { dVal = 255; } ucNormImg[i*iWidth + j] = (unsigned char)dVal; } } return 0; } //直方图均衡化单步测试 //参数:info(返回操作成功或失败提示信息) int Step3_Normalize(char *info) { //设置输入输出文件名 char srcTxtFile[MAX_PATH] = { STEP_TXT_2 };//源数据文件名 char srcImgFile[MAX_PATH] = { STEP_IMG_2 };//源图文件名 char dstTxtFile[MAX_PATH] = { STEP_TXT_3 };//结果数据文件名 char dstImgFile[MAX_PATH] = { STEP_IMG_3 };//结果图文件名 //读取图像参数 int iWidth, iHeight, iDepth;//图像宽度/高度/深度 ReadBMPImgFilePara(srcImgFile, iWidth, iHeight, iDepth); //读取源数据 unsigned char *image1 = new unsigned char[iWidth*iHeight]; ReadDataFromTextFile(srcTxtFile, image1, iWidth, iHeight); //直方图均衡化 unsigned char *image2 = new unsigned char[iWidth*iHeight]; HistoNormalize(image1, image2, iWidth, iHeight); //保存结果数据(TXT文件) SaveDataToTextFile(dstTxtFile, image2, iWidth, iHeight); //保存结果图像(BMP文件,仅用于显示) SaveDataToImageFile(srcImgFile, dstImgFile, image2); //释放空间 delete[] image1; delete[] image2; //返回操作成败状态 sprintf(info, "完成直方图均衡化."); return 0; } //指纹脊线方向计算 //ucImg(图像数据),fDirc(脊线方向数据),iWidth(图像宽度),iHeight(图像高度) int ImgDirection(unsigned char *ucImg, float *fDirc, int iWidth, int iHeight) { //定义变量 const int SEMISIZ = 7;//领域窗口区域半径 int dx[SEMISIZ * 2 + 1][SEMISIZ * 2 + 1]; int dy[SEMISIZ * 2 + 1][SEMISIZ * 2 + 1]; float fx, fy; //结果初始化 memset(fDirc, 0, iWidth*iHeight * sizeof(float)); //计算每一像素的脊线方向值 for (int y = SEMISIZ + 1; y < iHeight - SEMISIZ - 1; y++)//逐行遍历(除去边缘) { for (int x = SEMISIZ + 1; x < iWidth - SEMISIZ - 1; x++)//逐列遍历(除去边缘) { //计算以当前像素为中心的领域窗口区内每一像素的梯度 for (int j = 0; j < SEMISIZ * 2 + 1; j++) { for (int i = 0; i < SEMISIZ * 2 + 1; i++) { int index1 = (y + j - SEMISIZ)*iWidth + x + i - SEMISIZ; int index2 = (y + j - SEMISIZ)*iWidth + x + i - SEMISIZ - 1; int index3 = (y + j - SEMISIZ - 1)*iWidth + x + i - SEMISIZ; dx[i][j] = int(ucImg[index1] - ucImg[index2]); dy[i][j] = int(ucImg[index1] - ucImg[index3]); } } //计算当前像素的脊线方向值 fx = 0.0; fy = 0.0; for (int j = 0; j < SEMISIZ * 2 + 1; j++) { for (int i = 0; i < SEMISIZ * 2 + 1; i++) { fx += 2 * dx[i][j] * dy[i][j]; fy += (dx[i][j] * dx[i][j] - dy[i][j] * dy[i][j]); } } fDirc[y*iWidth + x] = atan2(fx, fy); } } return 0; } //脊线方向低通滤波 //fDirc(脊线方向原始数据),fFitDirc(脊线方向滤波结果数据),iWidth(图像宽度),iHeight(图像高度) int DircLowPass(float *fDirc, float *fFitDirc, int iWidth, int iHeight) { //定义变量 const int DIR_FILTER_SIZE = 2; int blocksize = 2 * DIR_FILTER_SIZE + 1; int imgsize = iWidth * iHeight; float* filter = new float[blocksize*blocksize];//使用5*5滤波器 float* phix = new float[imgsize]; float* phiy = new float[imgsize]; float* phi2x = new float[imgsize]; float* phi2y = new float[imgsize]; //结果初始化 memset(fFitDirc, 0, sizeof(float)*iWidth*iHeight); //设置5*5高斯低通滤波器模板 float tempSum = 0.0; for (int y = 0; y < blocksize; y++) { for (int x = 0; x < blocksize; x++) { filter[y*blocksize + x] = (float)(blocksize - (abs(DIR_FILTER_SIZE - x) + abs(DIR_FILTER_SIZE - y))); tempSum += filter[y*blocksize + x]; } } for (int y = 0; y < blocksize; y++) { for (int x = 0; x < blocksize; x++) { filter[y*blocksize + x] /= tempSum; } } //计算各像素点的方向正弦值和余弦值 for (int y = 0; y < iHeight; y++) { for (int x = 0; x < iWidth; x++) { phix[y*iWidth + x] = cos(fDirc[y*iWidth + x]); phiy[y*iWidth + x] = sin(fDirc[y*iWidth + x]); } } //对所有像素进行方向低通滤波 memset(phi2x, 0, sizeof(float)*imgsize); memset(phi2y, 0, sizeof(float)*imgsize); float nx, ny; int val; for (int y = 0; y <= iHeight - blocksize; y++)//逐行遍历(除去边缘区段) { for (int x = 0; x <= iWidth - blocksize; x++)//逐列遍历(除去边缘区段) { //对以当前像素为中心的滤波窗口内的所有像素值进行加权累加 nx = 0.0; ny = 0.0; for (int j = 0; j < blocksize; j++) { for (int i = 0; i < blocksize; i++) { val = (x + i) + (j + y)*iWidth; nx += filter[j*blocksize + i] * phix[val];//方向余弦加权累加 ny += filter[j*blocksize + i] * phiy[val];//方向正弦加权累加 } } //将累加结果作为当前像素的新的方向正弦值和余弦值 val = x + y * iWidth; phi2x[val] = nx; phi2y[val] = ny; } } //根据加权累加结果,计算各像素的方向滤波结果值 for (int y = 0; y < iHeight - blocksize; y++) { for (int x = 0; x < iWidth - blocksize; x++) { val = x + y * iWidth; fFitDirc[val] = atan2(phi2y[val], phi2x[val])*0.5; } } delete[] phi2y; delete[] phi2x; delete[] phiy; delete[] phix; return 0; } //指纹脊线方向计算单步测试 //参数:info(返回操作成功或失败提示信息) int Step4_Direction(char *info) { //设置输入输出文件名 char srcTxtFile[MAX_PATH] = { STEP_TXT_3 };//源数据文件名 char srcImgFile[MAX_PATH] = { STEP_IMG_3 };//源图文件名 char dstTxtFile[MAX_PATH] = { STEP_TXT_4 };//结果数据文件名 char dstImgFile[MAX_PATH] = { STEP_IMG_4 };//结果图文件名 //读取图像参数 int iWidth, iHeight, iDepth;//图像宽度/高度/深度 ReadBMPImgFilePara(srcImgFile, iWidth, iHeight, iDepth); //读取源数据 unsigned char *image1 = new unsigned char[iWidth*iHeight]; ReadDataFromTextFile(srcTxtFile, image1, iWidth, iHeight); //方向计算 float *tmpDirections = new float[iWidth*iHeight]; ImgDirection(image1, tmpDirections, iWidth, iHeight); //方向低通滤波 float *directions = new float[iWidth*iHeight]; DircLowPass(tmpDirections, directions, iWidth, iHeight); //保存结果数据(TXT文件) SaveDataToTextFile(dstTxtFile, directions, iWidth, iHeight); //保存结果图像(BMP文件,仅用于显示) const int DIRECTION_SCALE = 100;//方向结果转换比例(仅用于结果显示) SaveDataToImageFile(srcImgFile, dstImgFile, directions, DIRECTION_SCALE); //释放空间 delete[] image1; delete[] tmpDirections; delete[] directions; //返回操作成败状态 sprintf(info, "完成方向计算."); return 0; } //指纹脊线频率计算 //ucImg(源图数据),fDirection(脊线方向数据),fFrequency(脊线频率结果数据),iWidth(图像宽度),iHeight(图像高度) int Frequency(unsigned char * ucImg, float * fDirection, float * fFrequency, int iWidth, int iHeight) { if (iWidth <= 0 || iHeight <= 0 || !ucImg || !fDirection || !fFrequency) { return -1; } //窗口大小 const int SIZE_L = 32; const int SIZE_W = 16; const int SIZE_L2 = 16; const int SIZE_W2 = 8; //正弦波峰值点 int peak_pos[SIZE_L]; int peak_cnt; float peak_freq; float Xsig[SIZE_L]; //方向 float dir = 0.0; float cosdir = 0.0; float sindir = 0.0; float maxPeak, minPeak; //结果初始化 float *frequency1 = new float[iWidth*iHeight]; memset(fFrequency, 0, sizeof(float)*iWidth*iHeight); memset(frequency1, 0, sizeof(float)*iWidth*iHeight); int x, y; int d, k; int u, v; for (y = SIZE_L2; y < iHeight - SIZE_L2; y++)//逐行遍历(除去边缘区段) { for (x = SIZE_L2; x < iWidth - SIZE_L2; x++)//逐列遍历(除去边缘区段) { //当前像素的脊线方向 dir = fDirection[(y + SIZE_W2)*iWidth + (x + SIZE_W2)]; cosdir = -sin(dir); sindir = cos(dir); //计算以当前像素为中心的L*W邻域窗口的幅值序列,X[0]...X[L-1] for (k = 0; k < SIZE_L; k++) { Xsig[k] = 0.0; for (d = 0; d < SIZE_W; d++) { u = (int)(x + (d - SIZE_W2)*cosdir + (k - SIZE_L2)*sindir); v = (int)(y + (d - SIZE_W2)*sindir - (k - SIZE_L2)*cosdir); //边界点处理 if (u < 0) { u = 0; } else if (u > iWidth - 1) { u = iWidth - 1; } if (v < 0) { v = 0; } else if (v > iHeight - 1) { v = iHeight - 1; } Xsig[k] += ucImg[u + v * iWidth]; } Xsig[k] /= SIZE_W; } //确定幅值序列变化范围 maxPeak = minPeak = Xsig[0]; for (k = 0; k < SIZE_L; k++) { if (minPeak > Xsig[k]) { minPeak = Xsig[k]; } if (maxPeak < Xsig[k]) { maxPeak = Xsig[k]; } } //确定峰值点位置 peak_cnt = 0; if ((maxPeak - minPeak) > 64) { for (k = 0; k < SIZE_L; k++) { if ((Xsig[k - 1] < Xsig[k]) && (Xsig[k] >= Xsig[k + 1])) { peak_pos[peak_cnt++] = k; } } } //计算峰值点平均间距 peak_freq = 0.0; if (peak_cnt >= 2) { for (k = 0; k < peak_cnt - 1; k++) { peak_freq += (peak_pos[k + 1] - peak_pos[k]); } peak_freq /= peak_cnt - 1; } //计算当前像素的频率 if (peak_freq<3.0 || peak_freq>25.0) { frequency1[x + y * iWidth] = 0.0; } else { frequency1[x + y * iWidth] = 1.0 / peak_freq; } } } //对频率进行均值滤波 for (y = SIZE_L2; y < iHeight - SIZE_L2; y++)//逐行遍历(除去边缘区段) { for (x = SIZE_L2; x < iWidth - SIZE_L2; x++)//逐列遍历(除去边缘区段) { k = x + y * iWidth;//当前像素位置(在频率数组中的数组下标) peak_freq = 0.0; //使用以当前像素为中心的5*5邻域窗口进行均值滤波 for (v = -2; v <= 2; v++) { for (u = -2; u <= 2; u++) { peak_freq += frequency1[(x + u) + (y + v)*iWidth];//求频率累加和 } } fFrequency[k] = peak_freq / 25;//当前像素频率等于窗口内频率均值 } } delete[] frequency1; return 0; } //指纹脊线频率计算单步测试 //参数:info(返回操作成功或失败提示信息) int Step5_Frequency(char *info) { //设置输入输出文件名 char srcTxtFile_Img[MAX_PATH] = { STEP_TXT_3 };//图像源数据文件名 char srcTxtFile_Dir[MAX_PATH] = { STEP_TXT_4 };//方向源数据文件名 char srcImgFile[MAX_PATH] = { STEP_IMG_4 };//源图文件名 char dstTxtFile[MAX_PATH] = { STEP_TXT_5 };//结果数据文件名 char dstImgFile[MAX_PATH] = { STEP_IMG_5 };//结果图文件名 //读取图像参数 int iWidth, iHeight, iDepth; int flag = ReadBMPImgFilePara(srcImgFile, iWidth, iHeight, iDepth); //读取图像源数据 unsigned char *image1 = new unsigned char[iWidth*iHeight]; ReadDataFromTextFile(srcTxtFile_Img, image1, iWidth, iHeight); //读取方向源数据 float *direction = new float[iWidth*iHeight]; ReadDataFromTextFile(srcTxtFile_Dir, direction, iWidth, iHeight); //频率计算 float *frequency = new float[iWidth*iHeight]; Frequency(image1, direction, frequency, iWidth, iHeight); //保存结果数据(TXT文件) SaveDataToTextFile(dstTxtFile, frequency, iWidth, iHeight); //保存结果图像(BMP文件,仅用于显示) const int FREQUENCY_SCALE = 1000;//频率结果转换比例(仅用于结果显示) SaveDataToImageFile(srcImgFile, dstImgFile, frequency, FREQUENCY_SCALE); //释放内存空间 delete[] image1; delete[] direction; delete[] frequency; //返回操作成败状态 sprintf(info, "完成频率计算."); return 0; } //指纹掩码计算 //ucImg(源图数据),fDirection(脊线方向数据),fFrequency(脊线频率数据) //ucMask(掩码结果数据),iWidth(图像宽度),iHeight(图像高度) int GetMask(unsigned char * ucImg, float * fDirection, float * fFrequency, unsigned char * ucMask, int iWidth, int iHeight) { if (!ucImg || !fDirection || !fFrequency || !ucMask || iWidth <= 0 || iHeight <= 0) { return -1; } //第1步:阈值分割(像素频率位于指定范围之内则设为前景点,否则设为背景点) float freqMin = 1.0 / 25.0; float freqMax = 1.0 / 3.0; int x, y, k; int pos, posout; memset(ucMask, 0, iWidth*iHeight);//结果初始化(全为背景点) for (y = 0; y < iHeight; y++)//逐行遍历 { for (x = 0; x < iWidth; x++)//逐列遍历 { pos = x + y * iWidth; posout = x + y * iWidth; ucMask[posout] = 0; if (fFrequency[pos] >= freqMin && fFrequency[pos] <= freqMax) { ucMask[posout] = 255;//频率位于指定范围之内则设为前景点 } } } //第2步:填充孔洞(利用形态学的膨胀原理) for (k = 0; k < 4; k++)//重复膨胀多次(次数自定) { //标记前景点 for (y = 1; y < iHeight - 1; y++)//逐行遍历 { for (x = 1; x < iWidth - 1; x++)//逐列遍历 { //前景点的上下左右四个相邻点都标记为前景点(将8位像素值的最高位设为1予以标记) if (ucMask[x + y * iWidth] == 0xFF)//前景点 { ucMask[x - 1 + y * iWidth] |= 0x80; ucMask[x + 1 + y * iWidth] |= 0x80; ucMask[x + (y - 1) * iWidth] |= 0x80; ucMask[x + (y + 1) * iWidth] |= 0x80; } } } //判断和设置前景点 for (y = 1; y < iHeight - 1; y++)//逐行遍历 { for (x = 1; x < iWidth - 1; x++)//逐列遍历 { //将标记为前景点的像素都设为前景点 if (ucMask[x + y * iWidth]) { ucMask[x + y * iWidth] = 0xFF;//设为前景点(像素值为255) } } } } //第3步:去除边缘和孤立点(利用形态学的腐蚀原理) for (k = 0; k < 12; k++)//重复腐蚀多次(次数自定) { //标记背景点 for (y = 1; y < iHeight - 1; y++)//逐行遍历 { for (x = 1; x < iWidth - 1; x++)//逐列遍历 { //背景点的上下左右四个相邻点都标记为潜在背景点(将8位像素值的后7位都设为0予以标记) if (ucMask[x + y * iWidth] == 0x0)//背景点 { ucMask[x - 1 + y * iWidth] &= 0x80; ucMask[x + 1 + y * iWidth] &= 0x80; ucMask[x + (y - 1) * iWidth] &= 0x80; ucMask[x + (y + 1) * iWidth] &= 0x80; } } } //判断和设置背景点 for (y = 1; y < iHeight - 1; y++)//逐行遍历 { for (x = 1; x < iWidth - 1; x++)//逐列遍历 { //只要不是前景点的所有像素都设为背景点 if (ucMask[x + y * iWidth] != 0xFF)//非前景点 { ucMask[x + y * iWidth] = 0x0;//设为背景点(像素值为0) } } } } return 0; } //指纹掩码计算单步测试 //参数:info(返回操作成功或失败提示信息) int Step6_Mask(char *info) { //设置输入输出文件名 char srcTxtFile_Img[MAX_PATH] = { STEP_TXT_3 };//图像源数据文件名 char srcTxtFile_Dir[MAX_PATH] = { STEP_TXT_4 };//方向源数据文件名 char srcTxtFile_Fre[MAX_PATH] = { STEP_TXT_5 };//频率源数据文件名 char srcImgFile[MAX_PATH] = { STEP_IMG_5 };//源图文件名 char dstTxtFile[MAX_PATH] = { STEP_TXT_6 };//结果数据文件名 char dstImgFile[MAX_PATH] = { STEP_IMG_6 };//结果图文件名 //读取图像参数 int iWidth, iHeight, iDepth; ReadBMPImgFilePara(srcImgFile, iWidth, iHeight, iDepth); //读取图像源数据 unsigned char *image1 = new unsigned char[iWidth*iHeight]; ReadDataFromTextFile(srcTxtFile_Img, image1, iWidth, iHeight); //读取方向源数据 float *direction = new float[iWidth*iHeight]; ReadDataFromTextFile(srcTxtFile_Dir, direction, iWidth, iHeight); //读取频率源数据 float *frequency = new float[iWidth*iHeight]; ReadDataFromTextFile(srcTxtFile_Fre, frequency, iWidth, iHeight); //掩码计算 unsigned char *mask = new unsigned char[iWidth*iHeight]; GetMask(image1, direction, frequency, mask, iWidth, iHeight); //保存结果数据(TXT文件) SaveDataToTextFile(dstTxtFile, mask, iWidth, iHeight); //保存结果图像(BMP文件,仅用于显示) SaveDataToImageFile(srcImgFile, dstImgFile, mask); //释放空间 delete[] image1; delete[] mask; delete[] direction; delete[] frequency; //返回操作成败状态 sprintf(info, "完成掩码计算."); return 0; } //Gabor滤波增强 //ucImg(源图数据),fDirection(脊线方向数据),fFrequency(脊线频率数据),ucMask(掩码数据),ucImgEnhanced(滤波增强结果数据),iWidth(图像宽度),iHeight(图像高度) int GaborEnhance(unsigned char * ucImg, float * fDirection, float * fFrequency, unsigned char * ucMask, unsigned char * ucImgEnhanced, int iWidth, int iHeight) { //定义变量 const float PI = 3.141592654; int i, j, u, v; int wg2 = 5;//使用11*11的Gabor滤波器,半边长为5 float sum, f, g; float x2, y2; float dx2 = 1.0 / (4.0*4.0);//沿x轴方向的高斯包络常量 float dy2 = 1.0 / (4.0*4.0);//沿y轴方向的高斯包络常量 //结果初始化 memset(ucImgEnhanced, 0, iWidth*iHeight); //Gabor滤波 for (j = wg2; j < iHeight - wg2; j++)//逐行遍历(除去边缘区段) { for (i = wg2; i < iWidth - wg2; i++)//逐列遍历(除去边缘区段) { //跳过背景点 if (ucMask[i + j * iWidth] == 0)//掩码为0表示背景点 { continue; } //获取当前像素的方向和频率 g = fDirection[i + j * iWidth];//当前像素的脊线方向 f = fFrequency[i + j * iWidth];//当前像素的脊线频率 g += PI / 2;//垂直方向 //对当前像素进行Gabor滤波 sum = 0.0; for (v = -wg2; v <= wg2; v++)//滤波窗口逐行遍历 { for (u = -wg2; u <= wg2; u++)//滤波窗口逐列遍历 { x2 = -u * sin(g) + v * cos(g);//x坐标旋转 y2 = u * cos(g) + v * sin(g);//y坐标旋转 sum += exp(-0.5*(x2*x2*dx2 + y2 * y2*dy2))*cos(2 * PI*x2*f)*ucImg[(i - u) + (j - v)*iWidth];//窗口内滤波值累加 } } //边界值处理 if (sum > 255.0) { sum = 255.0; } if (sum < 0.0) { sum = 0.0; } //得到当前像素的滤波结果 ucImgEnhanced[i + j * iWidth] = (unsigned char)sum; } } return 0; } //Gabor滤波增强单步测试 //参数:info(返回操作成功或失败提示信息) int Step7_GaborEnhance(char *info) { //设置输入输出文件名 char srcTxtFile_Img[MAX_PATH] = { STEP_TXT_3 };//图像源数据文件名 char srcTxtFile_Dir[MAX_PATH] = { STEP_TXT_4 };//方向源数据文件名 char srcTxtFile_Fre[MAX_PATH] = { STEP_TXT_5 };//频率源数据文件名 char srcTxtFile_Msk[MAX_PATH] = { STEP_TXT_6 };//掩码源数据文件名 char srcImgFile[MAX_PATH] = { STEP_IMG_6 };//源图文件名 char dstTxtFile[MAX_PATH] = { STEP_TXT_7 };//结果数据文件名 char dstImgFile[MAX_PATH] = { STEP_IMG_7 };//结果图文件名 //读取图像参数 int iWidth, iHeight, iDepth; ReadBMPImgFilePara(srcImgFile, iWidth, iHeight, iDepth); //读取图像源数据 unsigned char *image1 = new unsigned char[iWidth*iHeight]; ReadDataFromTextFile(srcTxtFile_Img, image1, iWidth, iHeight); //读取方向源数据 float *direction = new float[iWidth*iHeight]; ReadDataFromTextFile(srcTxtFile_Dir, direction, iWidth, iHeight); //读取频率源数据 float *frequency = new float[iWidth*iHeight]; ReadDataFromTextFile(srcTxtFile_Fre, frequency, iWidth, iHeight); //读取掩码源数据 unsigned char *mask = new unsigned char[iWidth*iHeight]; ReadDataFromTextFile(srcTxtFile_Msk, mask, iWidth, iHeight); //Gabor滤波增强 unsigned char *image2 = new unsigned char[iWidth*iHeight]; GaborEnhance(image1, direction, frequency, mask, image2, iWidth, iHeight); //保存结果数据(TXT文件) SaveDataToTextFile(dstTxtFile, image2, iWidth, iHeight); //保存结果图像(BMP文件,仅用于显示) SaveDataToImageFile(srcImgFile, dstImgFile, image2); //释放内存空间 delete[] image1; delete[] direction; delete[] frequency; delete[] mask; delete[] image2; //返回操作成败状态 sprintf(info, "完成Gabor滤波增强."); return 0; } //图像二值化 //ucImage(源图数据),ucBinImage(结果图数据),iWidth(图像宽度),iHeight(图像高度),uThreshold(二值化灰度阈值) int BinaryImg(unsigned char * ucImage, unsigned char * ucBinImage, int iWidth, int iHeight, unsigned char uThreshold) { //分别定义指向源图数据和结果图数据的数据指针 unsigned char *pStart = ucImage, *pEnd = ucImage + iWidth * iHeight; unsigned char *pDest = ucBinImage; //逐一遍历所有元素 while (pStart < pEnd) { *pDest = *pStart > uThreshold ? 1 : 0;//二值化 pStart++;//源图数据指针后移 pDest++;//结果图数据指针后移 } return 0; } //二值图显示转换([0,1]->[0,255]) //ucImage(源图数据),ucGrayImage(结果图数据),iWidth(图像宽度),iHeight(图像高度) int BinaryToGray(unsigned char * ucBinImg, unsigned char * ucGrayImg, int iWidth, int iHeight) { //分别定义指向源图数据和结果图数据的数据指针 unsigned char *pStart = ucBinImg, *pEnd = ucBinImg + iWidth * iHeight; unsigned char *pDest = ucGrayImg; //逐一遍历所有元素 while (pStart < pEnd) { *pDest = *pStart > 0 ? 255 : 0;//取值转换([0,1]->[0,255]) pStart++;//源图数据指针后移 pDest++;//结果图数据指针后移 } return 0; } //二值化单步测试 //参数:info(返回操作成功或失败提示信息) int Step8_Binary(char *info) { //设置输入输出文件名 char srcTxtFile[MAX_PATH] = { STEP_TXT_7 };//源数据文件名 char srcImgFile[MAX_PATH] = { STEP_IMG_7 };//源图文件名 char dstTxtFile[MAX_PATH] = { STEP_TXT_8 };//结果数据文件名 char dstImgFile[MAX_PATH] = { STEP_IMG_8 };//结果图文件名 //读取图像参数 int iWidth, iHeight, iDepth; ReadBMPImgFilePara(srcImgFile, iWidth, iHeight, iDepth); //读取源数据 unsigned char *image1 = new unsigned char[iWidth*iHeight]; ReadDataFromTextFile(srcTxtFile, image1, iWidth, iHeight); //二值化 unsigned char *image2 = new unsigned char[iWidth*iHeight]; BinaryImg(image1, image2, iWidth, iHeight, 128); //保存结果数据(TXT文件) SaveDataToTextFile(dstTxtFile, image2, iWidth, iHeight); //保存结果图像(BMP文件,仅用于显示) BinaryToGray(image2, image1, iWidth, iHeight);//二值图显示转换 SaveDataToImageFile(srcImgFile, dstImgFile, image1); //释放内存空间 delete[] image1; delete[] image2; //返回操作成败状态 sprintf(info, "完成二值化."); return 0; } //图像细化 //ucBinedImg(源图数据),ucThinnedImage(结果图数据),iWidth(图像宽度),iHeight(图像高度),iIterativeLimit(最大迭代次数) int Thinning(unsigned char * ucBinedImg, unsigned char * ucThinnedImage, int iWidth, int iHeight, int iIterativeLimit) { if (iWidth <= 0 || iHeight <= 0 || iIterativeLimit <= 0 || !ucBinedImg || !ucThinnedImage) { return -1; } //定义变量 unsigned char x1, x2, x3, x4, x5, x6, x7, x8, xp; unsigned char g1, g2, g3, g4; unsigned char b1, b2, b3, b4; unsigned char np1, np2, npm; unsigned char *pUp, *pDown, *pImg; int iDeletedPoints = 0; //结果初始化 memcpy(ucThinnedImage, ucBinedImg, iWidth*iHeight); for (int it = 0; it < iIterativeLimit; it++)//重复执行,一直到无点可删为止 { iDeletedPoints = 0;//初始化本次迭代所删点数 //本次迭代内第1次遍历(使用条件G1&G2&G3) for (int i = 1; i < iHeight - 1; i++)//逐行遍历 { //初始化邻域指针 pUp = ucBinedImg + (i - 1)*iWidth; pImg = ucBinedImg + i * iWidth; pDown = ucBinedImg + (i + 1)*iWidth; for (int j = 1; j < iWidth - 1; j++)//逐列遍历 { //调整邻域指针 pUp++; pImg++;//当前像素(窗口中心像素) pDown++; //跳过背景点(背景点像素值为0) if (!*pImg) { continue; } //获取3*3邻域窗口内所有9个像素的灰度值 x6 = *(pUp - 1); x5 = *(pImg - 1); x4 = *(pDown - 1); x7 = *pUp; xp = *pImg; x3 = *pDown; x8 = *(pUp + 1); x1 = *(pImg + 1); x2 = *(pDown + 1); //判断条件G1 b1 = !x1 && (x2 == 1 || x3 == 1); b2 = !x3 && (x4 == 1 || x5 == 1); b3 = !x5 && (x6 == 1 || x7 == 1); b4 = !x7 && (x8 == 1 || x1 == 1); g1 = (b1 + b2 + b3 + b4) == 1; //判断条件G2 np1 = x1 || x2; np1 += x3 || x4; np1 += x5 || x6; np1 += x7 || x8; np2 = x2 || x3; np2 += x4 || x5; np2 += x6 || x7; np2 += x8 || x1; npm = np1 > np2 ? np2 : np1; g2 = npm >= 2 && npm <= 3; //判断条件G3和G4 g3 = (x1 && (x2 || x3 || !x8)) == 0; g4 = (x5 && (x6 || x7 || !x4)) == 0; //组合判断(使用条件G1&G2&G3) if (g1&&g2&&g3) { ucThinnedImage[iWidth*i + j] = 0;//删掉当前元素(置为背景点) ++iDeletedPoints;//本次迭代所删点数加1 } }//end for(j) 列 }//end for(i) 行 //结果同步 memcpy(ucBinedImg, ucThinnedImage, iWidth*iHeight); //本次迭代内第2次遍历(使用条件G1&G2&G4) for (int i = 1; i < iHeight - 1; i++)//逐行遍历 { //初始化邻域指针 pUp = ucBinedImg + (i - 1)*iWidth; pImg = ucBinedImg + i * iWidth; pDown = ucBinedImg + (i + 1)*iWidth; for (int j = 1; j < iWidth - 1; j++)//逐列遍历 { //调整邻域指针 pUp++; pImg++;//当前像素(窗口中心像素) pDown++; //跳过背景点(背景点像素值为0) if (!*pImg) { continue; } //获取3*3邻域窗口内所有9个像素的灰度值 x6 = *(pUp - 1); x5 = *(pImg - 1); x4 = *(pDown - 1); x7 = *pUp; xp = *pImg; x3 = *pDown; x8 = *(pUp + 1); x1 = *(pImg + 1); x2 = *(pDown + 1); //判断条件G1 b1 = !x1 && (x2 == 1 || x3 == 1); b2 = !x3 && (x4 == 1 || x5 == 1); b3 = !x5 && (x6 == 1 || x7 == 1); b4 = !x7 && (x8 == 1 || x1 == 1); g1 = (b1 + b2 + b3 + b4) == 1; //判断条件G2 np1 = x1 || x2; np1 += x3 || x4; np1 += x5 || x6; np1 += x7 || x8; np2 = x2 || x3; np2 += x4 || x5; np2 += x6 || x7; np2 += x8 || x1; npm = np1 > np2 ? np2 : np1; g2 = npm >= 2 && npm <= 3; //判断条件G3和G4 g3 = (x1 && (x2 || x3 || !x8)) == 0; g4 = (x5 && (x6 || x7 || !x4)) == 0; //组合判断(使用条件G1&G2&G4) if (g1&&g2&&g4) { ucThinnedImage[iWidth*i + j] = 0;//删掉当前元素(置为背景点) ++iDeletedPoints;//本次迭代所删点数加1 } }//end for(j) 列 }//end for(i) 行 //结果同步 memcpy(ucBinedImg, ucThinnedImage, iWidth*iHeight); //如果本次迭代已无点可删,则停止迭代 if (iDeletedPoints == 0) { break; } } //清除边缘区段 for (int i = 0; i < iHeight; i++) { for (int j = 0; j < iWidth; j++) { if (i < 16)//上边缘 { ucThinnedImage[i*iWidth + j] = 0; } else if (i >= iHeight - 16)//下边缘 { ucThinnedImage[i*iWidth + j] = 0; } else if (j < 16)//左边缘 { ucThinnedImage[i*iWidth + j] = 0; } else if (j >= iWidth - 16)//右边缘 { ucThinnedImage[i*iWidth + j] = 0; } } } return 0; } //细化单步测试 //参数:info(返回操作成功或失败提示信息) int Step9_Thinning(char *info) { //设置输入输出文件名 char srcTxtFile[MAX_PATH] = { STEP_TXT_8 };//源数据文件名 char srcImgFile[MAX_PATH] = { STEP_IMG_8 };//源图文件名 char dstTxtFile[MAX_PATH] = { STEP_TXT_9 };//结果数据文件名 char dstImgFile[MAX_PATH] = { STEP_IMG_9 };//结果图文件名 //读取图像参数 int iWidth, iHeight, iDepth; ReadBMPImgFilePara(srcImgFile, iWidth, iHeight, iDepth); //读取源数据 unsigned char *image1 = new unsigned char[iWidth*iHeight]; ReadDataFromTextFile(srcTxtFile, image1, iWidth, iHeight); //细化 unsigned char *image2 = new unsigned char[iWidth*iHeight]; Thinning(image1, image2, iWidth, iHeight, 200); //保存结果数据(TXT文件) SaveDataToTextFile(dstTxtFile, image2, iWidth, iHeight); //保存结果图像(BMP文件,仅用于显示) BinaryToGray(image2, image1, iWidth, iHeight);//二值图显示转换 SaveDataToImageFile(srcImgFile, dstImgFile, image1); //释放内存空间 delete[] image1; delete[] image2; //返回操作成败状态 sprintf(info, "完成细化."); return 0; } //指纹特征提取 //ucThinImg(源图数据),ucMinuImg(结果图数据),iWidth(图像宽度),iHeight(图像高度) int Extract(unsigned char * ucThinImg, unsigned char * ucMinuImg, int iWidth, int iHeight) { //定义变量 unsigned char *pDest = ucMinuImg;//结果图数据指针 unsigned char *pUp, *pDown, *pImg;//源图邻域指针 unsigned char x1, x2, x3, x4, x5, x6, x7, x8;//八邻点 unsigned char nc;//八邻点中黑点数量 int iMinuCount = 0;//特征点数量 //结果初始化(全设为0,表示都是非特征点) memset(pDest, 0, iWidth*iHeight); //遍历源图以提取指纹特征 for (int i = 1; i < iHeight - 1; i++)//逐行遍历 { //初始化邻域指针 pUp = ucThinImg + (i - 1)*iWidth; pImg = ucThinImg + i * iWidth; pDown = ucThinImg + (i + 1)*iWidth; for (int j = 1; j < iWidth - 1; j++)//逐列遍历 { //调整邻域指针 pUp++; pImg++; pDown++; //跳过背景点(背景点像素值为0) if (!*pImg) { continue; } //获取3*3邻域窗口内所有8个邻点像素的灰度值 x6 = *(pUp - 1); x5 = *(pImg - 1); x4 = *(pDown - 1); x7 = *pUp; x3 = *pDown; x8 = *(pUp + 1); x1 = *(pImg + 1); x2 = *(pDown + 1); //统计八邻点中黑点数量 nc = x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8; //特征点判断 if (nc == 1)//端点 { pDest[i*iWidth + j] = 1;//结果图中对应像素点设为1(表示端点) ++iMinuCount;//特征点数量加1 } else if (nc == 3)//分叉点 { pDest[i*iWidth + j] = 3;//结果图中对应像素点设为3(表示分叉点) ++iMinuCount;//特征点数量加1 } } } return iMinuCount;//返回特征点数量 } //特征提取单步测试 //参数:minuCount(返回特征点数量),info(返回操作成功或失败提示信息) int Step10_MinuExtract(int &minuCount, char *info) { //结果初始化 minuCount = 0; //设置输入输出文件名 char srcTxtFile[MAX_PATH] = { STEP_TXT_9 };//源数据文件名 char srcImgFile[MAX_PATH] = { STEP_IMG_9 };//源图文件名 char dstTxtFile[MAX_PATH] = { STEP_TXT_10 };//结果数据文件名 char dstImgFile[MAX_PATH] = { STEP_IMG_10 };//结果图文件名 //读取图像参数 int iWidth, iHeight, iDepth; ReadBMPImgFilePara(srcImgFile, iWidth, iHeight, iDepth); //读取源数据 unsigned char *image1 = new unsigned char[iWidth*iHeight]; ReadDataFromTextFile(srcTxtFile, image1, iWidth, iHeight); //特征提取 unsigned char *image2 = new unsigned char[iWidth*iHeight]; minuCount = Extract(image1, image2, iWidth, iHeight); //保存结果数据(TXT文件) SaveDataToTextFile(dstTxtFile, image2, iWidth, iHeight); //保存结果图像(BMP文件,仅用于显示) BinaryToGray(image2, image1, iWidth, iHeight);//二值图显示转换 SaveDataToImageFile(srcImgFile, dstImgFile, image1); //释放内存空间 delete[] image1; delete[] image2; //返回成败状态 sprintf(info, "完成特征提取."); return 0; } struct NEIGHBOR { int x;//横坐标(列坐标) int y;//纵坐标(行坐标) int type;//特征点类型(1-端点,3-分叉点) float Theta;//两点连线角度(弧度) float Theta2Ridge;//两点脊线方向夹角(弧度) float ThetaThisNibor;//相邻特征点的脊线方向(弧度) int distance;//两点距离(像素数量) }; //特征点结构 struct MINUTIAE { int x;//横坐标(列坐标) int y;//纵坐标(行坐标) int type;//特征点类型(1-端点,3-分叉点) float theta;//该点处的脊线方向(弧度) NEIGHBOR *neibors;//相邻特征点序列 }; //去除边缘特征点 //minutiaes(特征点数组),count(特征点数量),ucImg(源图数据),iWidth(图像宽度),iHeight(图像高度) int CutEdge(MINUTIAE * minutiaes, int count, unsigned char * ucImg, int iWidth, int iHeight) { //定义变量 int minuCount = count; int x, y, type; bool del; //初始化标记数组 int *pFlag = new int[minuCount];//标记数组(标记值:0-保留,1-删除) memset(pFlag, 0, sizeof(int)*minuCount);//初始化(全0全保留) //遍历所有特征点 for (int i = 0; i < minuCount; i++) { //获取当前特征点信息 y = minutiaes[i].y - 1;//纵坐标(行坐标) x = minutiaes[i].x - 1;//横坐标(列坐标) type = minutiaes[i].type;//特征点类型(1-端点,3-分叉点) //将当前特征点的删除标记初始化为true del = true; //根据当前特征点的位置判断其是否边缘特征点 if (x < iWidth / 2)//如果位于图像左半图 { if (abs(iWidth / 2 - x) > abs(iHeight / 2 - y))//如果位于图像左半图的左侧 { //在特征图中查找当前特征点同一行左侧是否还有其他特征点 while (--x >= 0)//逐一左移查找 { //如果在左侧存在其他特征点,则说明当前特征点不是边缘特征点,就无须删除 if (ucImg[x + y * iWidth] > 0)//特征图像素值(0-非特征点,1-端点,3-分叉点) { del = false;//删除标记置为false break;//停止当前特征点的左移查找过程 } } } else//如果位于图像左半图的右侧 { if (y > iHeight / 2)//如果位于图像左半图的右下侧 { //在特征图中查找当前特征点同一列下侧是否还有其他特征点 while (++y < iHeight)//逐一下移查找 { //如果在下侧存在其他特征点,则说明当前特征点不是边缘特征点,就无须删除 if (ucImg[x + y * iWidth] > 0)//特征图像素值(0-非特征点,1-端点,3-分叉点) { del = false;//删除标记置为false break;//停止当前特征点的下移查找过程 } } } else//如果位于图像左半图的右上侧 { //在特征图中查找当前特征点同一列上侧是否还有其他特征点 while (--y >= 0)//逐一上移查找 { //如果在上侧存在其他特征点,则说明当前特征点不是边缘特征点,就无须删除 if (ucImg[x + y * iWidth] > 0)//特征图像素值(0-非特征点,1-端点,3-分叉点) { del = false;//删除标记置为false break;//停止当前特征点的上移查找过程 } } } } } else//如果位于图像右半图 { if (abs(iWidth / 2 - x) > abs(iHeight / 2 - y))//如果位于图像右半图的右侧 { //在特征图中查找当前特征点同一行右侧是否还有其他特征点 while (++x < iWidth)//逐一右移查找 { //如果在右侧存在其他特征点,则说明当前特征点不是边缘特征点,就无须删除 if (ucImg[x + y * iWidth] > 0)//特征图像素值(0-非特征点,1-端点,3-分叉点) { del = false;//删除标记置为false break;//停止当前特征点的左移查找过程 } } } else//如果位于图像右半图的左侧 { if (y > iHeight / 2)//如果位于图像右半图的左下侧 { //在特征图中查找当前特征点同一列下侧是否还有其他特征点 while (++y < iHeight)//逐一下移查找 { //如果在下侧存在其他特征点,则说明当前特征点不是边缘特征点,就无须删除 if (ucImg[x + y * iWidth] > 0)//特征图像素值(0-非特征点,1-端点,3-分叉点) { del = false;//删除标记置为false break;//停止当前特征点的下移查找过程 } } } else//如果位于图像右半图的左上侧 { //在特征图中查找当前特征点同一列上侧是否还有其他特征点 while (--y >= 0)//逐一上移查找 { //如果在上侧存在其他特征点,则说明当前特征点不是边缘特征点,就无须删除 if (ucImg[x + y * iWidth] > 0)//特征图像素值(0-非特征点,1-端点,3-分叉点) { del = false;//删除标记置为false break;//停止当前特征点的上移查找过程 } } } } } //如果当前特征点是边缘特征点,则予以删除(在标记数组中将其标记设置为1) if (del)//如果当前特征点的删除标记为true,则表明其为边缘特征点,应予以删除 { pFlag[i] = 1;//在标记数组中将其标记设置为1(表示删除) continue;//继续判断结构数组中的下一个特征点 } } //重组特征点结构数组(在当前结构数组中将所有有效特征点前移) int newCount = 0;//有效特征点数量(同时也是重组后的有效特征点数组下标) for (int i = 0; i < minuCount; i++) { if (pFlag[i] == 0)//如果当前特征点需要保留(标记值:0-保留,1-删除) { memcpy(&minutiaes[newCount], &minutiaes[i], sizeof(MINUTIAE));//特征点结构整体复制 newCount++;//有效特征点下标后移(有效特征点数量加1) } } delete[] pFlag; pFlag = NULL; //返回有效特征点数量 return newCount; } //特征过滤 //minuData(特征图数据),thinData(细化图数据),minutiaes(特征点数组),minuCount(特征点数量),iWidth(图像宽度),iHeight(图像高度) int MinuFilter(unsigned char *minuData, unsigned char *thinData, MINUTIAE *minutiaes, int &minuCount, int iWidth, int iHeight) { //第1步:计算细化图中各点方向 float *dir = new float[iWidth*iHeight]; memset(dir, 0, iWidth*iHeight * sizeof(float)); ImgDirection(thinData, dir, iWidth, iHeight);//计算脊线方向 //第2步:从特征图中提取特征点数据 unsigned char *pImg; unsigned char val; int temp = 0; for (int i = 1; i < iHeight - 1; i++)//逐行遍历 { pImg = minuData + i * iWidth; for (int j = 1; j < iWidth - 1; j++)//逐列遍历 { //获取特征图数据 ++pImg;//特征图指针后移 val = *pImg;//特征图像素值(0-非特征点,1-端点,3-分叉点) //提取特征点数据 if (val > 0) { minutiaes[temp].x = j + 1;//横坐标(从1开始) minutiaes[temp].y = i + 1;//纵坐标(从1开始) minutiaes[temp].theta = dir[i*iWidth+j];//脊线方向 minutiaes[temp].type = int(val);//特征点类型(1-端点,3-分叉点) ++temp;//特征点数组指针后移 } } } delete[] dir; //第3步:去除边缘特征点 minuCount = CutEdge(minutiaes, minuCount, thinData, iWidth, iHeight); //第4步:去除毛刺/小孔/间断等伪特征点 //初始化标记数组 int *pFlag = new int[minuCount];//标记数组(标记值:0-保留,1-删除) memset(pFlag, 0, sizeof(int)*minuCount); //遍历所有特征点 int x1, x2, y1, y2, type1, type2; for (int i = 0; i < minuCount; i++)//特征点1遍历 { //获取特征点1的信息 x1 = minutiaes[i].x; y1 = minutiaes[i].y; type1 = minutiaes[i].type;//特征点类型(1-端点,3-分叉点) for (int j = i+1; j < minuCount; j++)//特征点2遍历 { //跳过已删特征点 if (pFlag[j] == 1) { continue; } //获取特征点2的信息 x2 = minutiaes[j].x; y2 = minutiaes[j].y; type2 = minutiaes[j].type;//特征点类型(1-端点,3-分叉点) //计算两点间距 int r = (int)sqrt(float((y1 - y2)*(y1 - y2) + (x1 - x2)*(x1 - x2))); //删除间距过小的特征点 if (r <= 4)//如果间距不大于4则认为间距过小(间距阈值可自定) { if (type1 == type2)//如果两点类型相同 { if (type1 == 1)//如果两点都是端点,则认定为"短线或纹线间断" { pFlag[i] = pFlag[j] = 1;//同时删掉两点 } else//如果两点都是分叉点,则认定为"小孔" { pFlag[j] = 1;//只删掉点2 } } else if (type1 == 1)//如果点1是端点而点2是分叉点,则点1为"毛刺" { pFlag[i] = 1;//只删掉点1 } else//如果点1是分叉点而点2是端点,则认定点2为"毛刺" { pFlag[j] = 1;//只删掉点2 } } } } //重组特征点结构数组(在当前结构数组中将所有有效特征点前移) int newCount = 0;//有效特征点数量(同时也是重组后的有效特征点数组下标) for (int i = 0; i < minuCount; i++) { if (pFlag[i] == 0)//如果当前特征点需要保留(标记值:0-保留,1-删除) { memcpy(&minutiaes[newCount], &minutiaes[i], sizeof(MINUTIAE));//特征点结构整体复制 newCount++;//有效特征点下标后移(有效特征点数量加1) } } delete[] pFlag; minuCount = newCount;//保存有效特征点数量 //返回结果 return 0; } //保存特征模板文件 //minutiaes(特征点数组),count(特征点数量),fileName(模板文件名) int SaveMinutiae(MINUTIAE * minutiaes, int count, char * fileName) { //打开文件(二进制写入方式) FILE *fp = fopen(fileName, "wb"); if (!fp) { return -1; } //将所有特征点的结构体数据整体写入文件 const static int TemplateFileFlag = 0x3571027f; fwrite(&TemplateFileFlag, sizeof(int), 1, fp);//写入特征模板文件标记 fwrite(&count, sizeof(int), 1, fp);//写入特征点数量 for (int i = 0; i < count; i++)//逐一写入所有特征点 { fwrite(&(minutiaes[i]), sizeof(MINUTIAE), 1, fp);//将特征点结构整体写入 } //关闭文件 fclose(fp); return 0; } //特征过滤单步测试 //参数:minuCount(特征点数量),info(返回操作成功或失败提示信息) int Step11_MinuFilter(int &minuCount, char *info) { //设置输入输出文件名 char srcTxtFile_Minu[MAX_PATH] = { STEP_TXT_10 };//特征图源数据文件名 char srcTxtFile_Thin[MAX_PATH] = { STEP_TXT_9 };//细化图源数据文件名 char srcImgFile[MAX_PATH] = { STEP_IMG_10 };//源图文件名 char dstTxtFile[MAX_PATH] = { STEP_TXT_11 };//结果数据文件名 char dstImgFile[MAX_PATH] = { STEP_IMG_11 };//结果图文件名 char dstMdlFile[MAX_PATH] = { STEP_IMG_11_MDL };//结果模板文件名 //读取图像参数 int iWidth, iHeight, iDepth; ReadBMPImgFilePara(srcImgFile, iWidth, iHeight, iDepth); //读取特征图源数据 unsigned char *image1 = new unsigned char[iWidth*iHeight]; ReadDataFromTextFile(srcTxtFile_Minu, image1, iWidth, iHeight); //读取细化图源数据 unsigned char *thin = new unsigned char[iWidth*iHeight]; ReadDataFromTextFile(srcTxtFile_Thin, thin, iWidth, iHeight); //特征过滤 MINUTIAE *minutiaes = new MINUTIAE[minuCount]; memset(minutiaes, sizeof(MINUTIAE), minuCount); MinuFilter(image1, thin, minutiaes, minuCount, iWidth, iHeight); //保存模板文件 SaveMinutiae(minutiaes, minuCount, dstMdlFile); //生成结果图像 unsigned char *image2 = new unsigned char[iWidth*iHeight]; memset(image2, 0, iWidth*iHeight); for (int i = 0; i < minuCount; i++) { image2[(minutiaes[i].y - 1)*iWidth + (minutiaes[i].x - 1)] = 0xff; } //保存结果数据(TXT文件) SaveDataToTextFile(dstTxtFile, image2, iWidth, iHeight); //保存结果图像(BMP文件,仅用于显示) SaveDataToImageFile(srcImgFile, dstImgFile, image2); //释放空间 delete[] image1; delete[] thin; delete[] minutiaes; delete[] image2; //返回成败状态 sprintf(info, "完成特征过滤."); return 0; } //获得新指纹编号 int GetNewIndexInDB() { //从index文件中读取最后一条记录的编号 int sNo = 0; char name[MAX_PATH] = { 0 }, srcFile[MAX_PATH] = { 0 }, mdlFile[MAX_PATH] = { 0 }; FILE *index = fopen(DB_INDEX_TXT, "r"); if (!index) { return -1; } while (!feof(index)) { fscanf(index, "%d %s %s %s \n", &sNo, srcFile, mdlFile, name); } fclose(index); //生成新编号 sNo = sNo + 1; //返回新编号 return sNo; } //特征入库单步测试 //参数:userName(登记人姓名)info(返回操作成功或失败提示信息) int Step12_Enroll(char *userName,char *info) { //设置输入文件名 char srcImgFile[MAX_PATH] = { STEP_IMG_1 };//源图文件名 char srcMdlFile[MAX_PATH] = { STEP_IMG_11_MDL };//模板文件名 //获得数据库内新指纹记录编号 int sNo = GetNewIndexInDB(); //设置用户名/源图文件名/模板文件名等需要存入数据库的指纹登记信息 char regName[MAX_PATH] = { 0 };//登记人姓名 char dstImgFile[MAX_PATH] = { 0 };//源图文件 char dstMdlFile[MAX_PATH] = { 0 };//源模板文件 sprintf(regName, userName);//直接复制界面输入内容 sprintf(dstImgFile, "%s%d.bmp", DB_DIR, sNo);//存入数据库文件夹内,以编号命名 sprintf(dstMdlFile, "%s%d.mdl", DB_DIR, sNo);//存入数据库文件夹内,以编号命名 //保存原始图像 CopyFile(ToWideChar(srcImgFile), ToWideChar(dstImgFile), false); //保存模板文件 CopyFile(ToWideChar(srcMdlFile), ToWideChar(dstMdlFile), false); //指纹登记信息写入数据库索引文件 FILE *index = fopen(DB_INDEX_TXT, "a");//追加模式写入 fprintf(index, "%d %s %s %s\n", sNo, dstImgFile, dstMdlFile, regName); fclose(index); sprintf(info, "完成指纹入库."); return 0; } //宽字符串转换为多字节字符串 char *ToChar(wchar_t *str) { int num = WideCharToMultiByte(0, 0, str, -1, NULL, 0, NULL, false); char *chStr = new char[num]; WideCharToMultiByte(0, 0, str, -1, chStr, num, NULL, false); return chStr; } //计算线段倾斜度 //x1(端点1横坐标),y1(端点1纵坐标),x2(端点2横坐标),y2(端点2纵坐标) float Angle2Points(int x1, int y1, int x2, int y2) { const float PI = 3.141592654; float diffY, diffX; float theta = 0.0; diffY = y2 - y1; diffX = x2 - x1; if (diffY < 0 && diffX > 0) { theta = atan2(-1 * diffY, diffX); } else if (diffY < 0 && diffX < 0) { theta = PI - atan2(-1 * diffY, -1 * diffX); } else if (diffY > 0 && diffX < 0) { theta = atan2(diffY, -1 * diffX); } else if (diffY > 0 && diffX > 0) { theta = PI - atan2(diffY, diffX); } else if (diffX == 0) { theta = PI / 2; } else { theta = 0.0; } return theta; } //构建特征点相邻关系 //minutiae(特征点数组),minuCount(特征点数量) int BuildNabors(MINUTIAE * minutiae, int minuCount) { //定义变量 const int MAX_NEIGHBOR_EACH = 10;//每个特征点最多保存10个相邻特征点 int x1, x2, y1, y2; int *pFlag = new int[minuCount];//相邻标记数组(标记值:0-不相邻,1-相邻) //遍历特征点数组 for (int i = 0; i < minuCount; i++) { //获取当前特征点信息 x1 = minutiae[i].x; y1 = minutiae[i].y; //初始化当前特征点的相邻标记数组 memset(pFlag, 0, sizeof(int)*minuCount);//初始化为全0(不相邻) pFlag[i] = 1;//将自身标记为"相邻" //为当前特征点创建并初始化相邻特征点结构数组 minutiae[i].neibors = new NEIGHBOR[MAX_NEIGHBOR_EACH];//创建相邻特征点结构数组 if (minutiae[i].neibors == NULL) { return -1; } memset(minutiae[i].neibors, 0, sizeof(NEIGHBOR)*MAX_NEIGHBOR_EACH);//初始化数组 //查找和保存10个相邻特征点 for (int neighborNo = 0; neighborNo < MAX_NEIGHBOR_EACH; neighborNo++)//重复10次 { //初始化最小间距和对应特征点下标 int minDistance = 1000;//最小间距 int minNo = 0;//最小间距对应的特征点下标 //查找相邻特征点之外的最近的不相邻特征点 for (int j = 0; j < minuCount; j++)//每次都遍历所有特征点 { //跳过已找到的相邻特征点 if (pFlag[j] == 1)//(标记值:0-不相邻,1-相邻) { continue; } //获取特征点2的信息 x2 = minutiae[j].x; y2 = minutiae[j].y; //计算两点间距 int r = (int)sqrt(float((y1 - y2)*(y1 - y2) + (x1 - x2)*(x1 - x2))); //查找最小间距 if (r < minDistance) { minNo = j; minDistance = r; } } //保存查找结果 pFlag[minNo] = 1;//将找到的最近的不相邻特征点的标记设置为"相邻" minutiae[i].neibors[neighborNo].x = minutiae[minNo].x;//横坐标(列坐标) minutiae[i].neibors[neighborNo].y = minutiae[minNo].y;//纵坐标(行坐标) minutiae[i].neibors[neighborNo].type = minutiae[minNo].type;//特征点类型(1-端点,3-分叉点) minutiae[i].neibors[neighborNo].Theta = Angle2Points(minutiae[minNo].x, minutiae[minNo].y, x1, y1);//两点连线角度(弧度) minutiae[i].neibors[neighborNo].Theta2Ridge = minutiae[minNo].theta - minutiae[i].theta;//两点脊线方向夹角(弧度) minutiae[i].neibors[neighborNo].ThetaThisNibor = minutiae[minNo].theta;//相邻特征点的脊线方向(弧度) minutiae[i].neibors[neighborNo].distance = minDistance;//两点距离 } } delete[] pFlag; return 0; } //特征匹配相似度计算 //iWidth(图像宽度),iHeight(图像高度),minutiae1(指纹一的特征点数组),account1(指纹一的特征点数量),minutiae2(指纹二的特征点数组),account2(指纹二的特征点数量) float MinuSimilarity(int iWidth, int iHeight, MINUTIAE *minutiae1, int count1, MINUTIAE *minutiae2, int count2) { const int MAX_SIMILAR_PAIR = 100;//最多保存100对配对相似特征点 const int MAX_NEIGHBOR_EACH = 10;//每个特征点最多保存10个相邻特征点 //构建特征点相邻关系 BuildNabors(minutiae1, count1); BuildNabors(minutiae2, count2); //初始化特征点匹配结果(相似特征点点对) int similarPair[MAX_SIMILAR_PAIR][2]; memset(similarPair, 0, 100 * 2 * sizeof(int)); //选择基准特征和参考特征 MINUTIAE * baseMinutiae;//基准特征点数组(含特征点较少) MINUTIAE * refMinutiae;//参考特征点数组(含特征点较多) int baseAccount, refAccount; if (count1 < count2) { baseMinutiae = minutiae1; baseAccount = count1; refMinutiae = minutiae2; refAccount = count2; } else { baseMinutiae = minutiae2; baseAccount = count2; refMinutiae = minutiae1; refAccount = count1; } //方便起见,下文中"特征点"均简称为"点",例如"基准点/参考点/相邻点/相似点"等 NEIGHBOR *baseNeighbors = NULL;//基准点的相邻点指针 NEIGHBOR *refNeighbors = NULL;//参考点的相邻点指针 int similarMinutiae = 0;//相似点对数量(数组下标) float baseTheta, refTheta;//基准方向和参考方向 //特征点匹配(在参考点数组中寻找与每一个基准点对应的最相似的参考点) for (int i = 0; i < baseAccount; i++)//逐一遍历基准点数组 { //获取当前基准点信息 baseNeighbors = baseMinutiae[i].neibors;//基准点的相邻点数组 baseTheta = baseMinutiae[i].theta;//基准点的脊线方向 //在参考点数组中寻找与当前基准点最相似的参考点 int refSimilarNo = 0; int maxSimilarNeibors = 0; for (int j = 0; j < refAccount; j++)//逐一遍历参考点数组 { //跳过与当前基准点类型不同的参考点 if (refMinutiae[j].type != baseMinutiae[i].type) { continue; } //获取当前参考点信息 refNeighbors = refMinutiae[j].neibors;//参考点的相邻点数组 refTheta = refMinutiae[j].theta;//参考点的脊线方向 //统计相似相邻点数量 int thisSimilarNeigbors = 0;//相似相邻点数量初始化为0 for (int m = 0; m < MAX_NEIGHBOR_EACH; m++)//逐一遍历当前基准点的相邻点数组 { //在当前参考点的相邻点数组中查找与当前基准点的当前相似点相似的相邻点 for (int n = 0; n < MAX_NEIGHBOR_EACH; n++)//逐一遍历当前参考点的相邻点数组 { //跳过类型不同的相邻点 if (baseNeighbors[m].type != refNeighbors[n].type) { continue; } //计算两个相邻点之间的距离差和不同角度差(弧度) int dist = abs(int(baseNeighbors[m].distance - refNeighbors[n].distance)); float theta1 = abs(float((baseNeighbors[m].Theta - baseTheta) - (refNeighbors[n].Theta - refTheta))); float theta2 = abs(float(baseNeighbors[m].Theta2Ridge - refNeighbors[n].Theta2Ridge)); float theta3 = abs(float((baseNeighbors[m].Theta - baseNeighbors[m].ThetaThisNibor) - (refNeighbors[n].Theta - refNeighbors[n].ThetaThisNibor))); //如果距离差小于指定阈值(此处取4)并且角度差均小于指定阈值(此处取0.15),则认为这两个相邻点相似 if (dist < 4 && theta1 < 0.15f&&theta2 < 0.15f&&theta3 < 0.15f) { ++thisSimilarNeigbors;//相似相邻点数量加1 break;//转向当前基准点的下一个相邻点继续查找 } } } //如果3对以上相邻点相似,则认为当前基准点与当前参考点相似,保存匹配结果 if ((thisSimilarNeigbors >= MAX_NEIGHBOR_EACH * 3 / 10) && (similarMinutiae < MAX_SIMILAR_PAIR)) { similarPair[similarMinutiae][0] = i;//保存当前基准点下标 similarPair[similarMinutiae][1] = refSimilarNo;//保存当前参考点下标 ++similarMinutiae;//相似点对数量加1(数组下标后移) } } } //计算特征匹配相似度 float similarity = similarMinutiae / 8.0f; //如果相似特征点数量小于指定下限阈值(此处取2),则认为两个指纹完全不匹配 similarity = similarMinutiae < 2 ? 0.0f : similarity;//边界值处理 //如果相似特征点数量大于指定上限阈值(此处取8),则认为两个指纹完全匹配 similarity = similarMinutiae > 8 ? 1.0f : similarity;//边界值处理 //返回特征匹配相似度 return similarity; } //读取特征模板文件 //fileName(特征模板文件名),minutiae(特征点数组) //读取特征模板文件 int ReadMinutiae(char * fileName, MINUTIAE ** minutiae) { //打开文件(二进制读取方式) FILE *fp = fopen(fileName, "rb"); if (!fp) { return -1; } //注意整体读取所有特征点的结构体数组 const static int TemplateFileFlag = 0x3571027f; int flag; fread(&flag, sizeof(int), 1, fp);//读取特征模板文件标记 if (flag != TemplateFileFlag) { return -2; } int account; fread(&account, sizeof(int), 1, fp);//读取特征点数量 *minutiae = new MINUTIAE[account];//创建特征点结构数组 if (*minutiae == NULL) { return -3; } for (int i = 0; i < account; i++)//逐一读取所有特征点 { fread(&((*minutiae)[i]), sizeof(MINUTIAE), 1, fp);//整体读取特征点结构 } //关闭文件 fclose(fp); return account; } //特征匹配单步测试 //参数:info(返回操作成功或失败提示信息) int Step12_Match(char *info) { //设置输入输出文件名 char srcImgFile[MAX_PATH] = { STEP_IMG_1 };//源图文件名 char srcMdlFile[MAX_PATH] = { STEP_IMG_11_MDL };//模板文件名 char dstImgFile[MAX_PATH] = { STEP_IMG_12 };//结果图文件名 //读取图像参数 int iWidth, iHeight, iDepth; ReadBMPImgFilePara(srcImgFile, iWidth, iHeight, iDepth); //读取指纹特征数据 MINUTIAE *minu = NULL; int minuAccount = ReadMinutiae(srcMdlFile, &minu); //特征匹配(此处仅测试自身与自身匹配) float similar = MinuSimilarity(iWidth, iHeight, minu, minuAccount, minu, minuAccount); //释放内存空间 delete[] minu; //保存匹配结果图像 CopyFile(ToWideChar(srcImgFile), ToWideChar(dstImgFile), false);//复制文件 //返回操作成败状态 const float SIMILAR_THRED = 0.1;//匹配相似度阈值(小于阈值则认为不匹配) if (similar < SIMILAR_THRED) { sprintf(info, "匹配失败."); return -3; } sprintf(info, "匹配成功:相似度[%.2f].", similar); return 0; } //指纹库预检(判断指纹库是否为空) bool EmptyDB() { //打开文件 char indexFile[MAX_PATH] = { DB_INDEX_TXT };//指纹库索引文件 FILE *pFile = fopen(indexFile, "r"); if (!pFile)//若索引文件不存在或存在异常,则指纹库为空 { return true; } //判断指纹库是否为空(索引文件内容是否为空) int size = _filelength(_fileno(pFile));//文件长度(以字节为单位) bool bEmpty = (size < 1) ? true : false;//若索引文件内容为空,则指纹库为空 //关闭文件 fclose(pFile); //返回判断结果 return bEmpty; } //指纹识别单步测试 //参数:info(返回操作成功或失败提示信息) int Step12_Identify(char *info) { //设置输入输出文件名 char srcImgFile[MAX_PATH] = { STEP_IMG_1 };//源图文件名 char srcMdlFile[MAX_PATH] = { STEP_IMG_11_MDL };//源图指纹特征文件名 char dstImgFile[MAX_PATH] = { STEP_IMG_12 };//结果图文件名 char dstMdlFile[MAX_PATH] = { 0 };//结果图指纹特征文件名 //指纹库预检(判断指纹库是否为空) EmptyDB(); //读取图像参数 int iWidth, iHeight, iDepth; ReadBMPImgFilePara(srcImgFile, iWidth, iHeight, iDepth); //读取指纹特征数据 MINUTIAE *minu1 = NULL, *minu2 = NULL; int minuAccount1 = 0, minuAccount2 = 0; minuAccount1 = ReadMinutiae(srcMdlFile, &minu1); //特征识别 int id = 0; char name[MAX_PATH] = { 0 }, src[MAX_PATH] = { 0 }, mdl[MAX_PATH] = { 0 }; float maxSimilar = -1; int maxID = -1; char maxName[MAX_PATH] = { 0 }, maxSrc[MAX_PATH] = { 0 }; FILE *index = fopen(DB_INDEX_TXT, "r");//打开指纹库索引文件 while (!feof(index)) { //读取指纹记录信息(指纹编号/指纹图像文件名/特征模板文件名/登记人姓名/登记人学号) fscanf(index, "%d %s %s %s\n", &id, src, mdl, name); sprintf(dstMdlFile, mdl); //从特征模板文件中读取指纹特征 minuAccount2 = ReadMinutiae(dstMdlFile, &minu2); //特征匹配 float similar = MinuSimilarity(iWidth, iHeight, minu1, minuAccount1, minu2, minuAccount2); //保存相似度最高的指纹记录信息 if (similar > maxSimilar) { maxSimilar = similar; maxID = id; sprintf(maxName, name); sprintf(maxSrc, src); } } fclose(index);//关闭文件 //释放内存空间 delete[] minu1; delete[] minu2; //返回识别结果 const float SIMILAR_THRED = 0.1;//匹配相似度阈值(小于阈值则认为不匹配) if (maxID < 0 || maxSimilar < SIMILAR_THRED) { sprintf(info, "识别失败."); return -2; } CopyFile(ToWideChar(maxSrc), ToWideChar(dstImgFile), false);//复制识别结果图像 sprintf(info, "识别成功!\n识别结果:姓名[%s],目标指纹[%s],相似度[%.2f].", maxName, maxSrc, maxSimilar); return 0; } int flag1 = 0; int flag2 = 0; int flag3 = 0; //按钮:载入图像 void CFingerDlg::OnBnClickedBtnStep1() { char info[MAX_PATH] = { 0 }; Step1_LoadBmpImage(info); m_staticInfo.SetWindowText(ToWideChar(info)); ShowImageInCtrl(m_picCtrl1, STEP_IMG_1); flag1 = 1; } //按钮:指纹库信息 void CFingerDlg::OnBnClickedBtnDatabase() { char info[MAX_PATH] = { 0 };//初始化显示信息 GetDatabaseInfo(info);//获取指纹库信息 m_staticInfo.SetWindowText(ToWideChar(info));//显示指纹库信息 } //按钮:特征提取 void CFingerDlg::OnBnClickedBtnStep12b2() { if (flag1 == 0) { MessageBox(_T("尚未载入图像!"), _T("提示")); return; } //初始化操作结果信息 char info[MAX_PATH] = { 0 }; //中值滤波 int x2=Step2_MidFilter(info); m_staticInfo.SetWindowText(ToWideChar(info)); if (!x2) { ShowImageInCtrl(m_picCtrl2, STEP_IMG_2); } //均衡化 int x3=Step3_Normalize(info); m_staticInfo.SetWindowText(ToWideChar(info)); if (!x3) { ShowImageInCtrl(m_picCtrl3, STEP_IMG_3); } //方向计算 int x4=Step4_Direction(info); m_staticInfo.SetWindowText(ToWideChar(info)); if (!x4) { ShowImageInCtrl(m_picCtrl4, STEP_IMG_4); } //频率计算 int x5=Step5_Frequency(info); m_staticInfo.SetWindowText(ToWideChar(info)); if (!x5) { ShowImageInCtrl(m_picCtrl5, STEP_IMG_5); } //掩码计算 int x6=Step6_Mask(info); m_staticInfo.SetWindowText(ToWideChar(info)); if (!x6) { ShowImageInCtrl(m_picCtrl6, STEP_IMG_6); } //Gabor增强 int x7=Step7_GaborEnhance(info); m_staticInfo.SetWindowText(ToWideChar(info)); if (!x7) { ShowImageInCtrl(m_picCtrl7, STEP_IMG_7); } //二值化 int x8=Step8_Binary(info); m_staticInfo.SetWindowText(ToWideChar(info)); if (!x8) { ShowImageInCtrl(m_picCtrl8, STEP_IMG_8); } //细化 int x9=Step9_Thinning(info); m_staticInfo.SetWindowText(ToWideChar(info)); if (!x9) { ShowImageInCtrl(m_picCtrl9, STEP_IMG_9); } //特征提取 int x10=Step10_MinuExtract(m_minuCount, info); m_staticInfo.SetWindowText(ToWideChar(info)); if (!x10) { ShowImageInCtrl(m_picCtrl10, STEP_IMG_10); } //特征过滤 int x11=Step11_MinuFilter(m_minuCount, info); m_staticInfo.SetWindowText(ToWideChar(info)); if (!x10) { ShowImageInCtrl(m_picCtrl11, STEP_IMG_11); } flag2 = 1; } //特征入库 void CFingerDlg::OnBnClickedBtnStep12a() { if (flag2 == 0) { MessageBox(_T("尚未完成指纹提取!"), _T("提示")); return; } char info[MAX_PATH] = { 0 }; //获取界面输入内容 UpdateData(true); if (m_name.GetLength() == 0) { MessageBox(_T("请输入姓名!"), _T("提示")); return; } Step12_Enroll(ToChar(m_name.GetBuffer()),info); m_staticInfo.SetWindowText(ToWideChar(info)); flag3 = 1; } //指纹匹配 void CFingerDlg::OnBnClickedBtnStep12b() { if (flag3 == 0) { MessageBox(_T("尚未完成指纹入库!"), _T("提示")); return; } char info[MAX_PATH] = { 0 }; Step12_Identify(info); m_staticInfo.SetWindowText(ToWideChar(info)); ShowImageInCtrl(m_picCtrl12, STEP_IMG_12); } //退出并且删除temp目录和Database目录 void CFingerDlg::OnBnClickedBtnExit() { CString strDir(TEMP); if (strDir.IsEmpty()) { RemoveDirectory(strDir); return; } //首先删除文件及子文件夹 CFileFind ff; BOOL bFound = ff.FindFile(strDir + _T("\\*"), 0); while (bFound) { bFound = ff.FindNextFile(); if (ff.GetFileName() == _T(".") || ff.GetFileName() == _T("..")) continue; //去掉文件(夹)只读等属性 SetFileAttributes(ff.GetFilePath(), FILE_ATTRIBUTE_NORMAL); if (ff.IsDirectory()) { //递归删除子文件夹 //DeleteDirectory(ff.GetFilePath()); RemoveDirectory(ff.GetFilePath()); } else { DeleteFile(ff.GetFilePath()); //删除文件 } } ff.Close(); //然后删除该文件夹 RemoveDirectory(strDir); CString strDir2(DB); if (strDir2.IsEmpty()) { RemoveDirectory(strDir2); return; } //首先删除文件及子文件夹 CFileFind ff2; BOOL bFound2 = ff2.FindFile(strDir2 + _T("\\*"), 0); while (bFound2) { bFound2 = ff2.FindNextFile(); if (ff2.GetFileName() == _T(".") || ff2.GetFileName() == _T("..")) continue; //去掉文件(夹)只读等属性 SetFileAttributes(ff2.GetFilePath(), FILE_ATTRIBUTE_NORMAL); if (ff2.IsDirectory()) { //递归删除子文件夹 //DeleteDirectory(ff.GetFilePath()); RemoveDirectory(ff2.GetFilePath()); } else { DeleteFile(ff2.GetFilePath()); //删除文件 } } ff.Close(); //然后删除该文件夹 RemoveDirectory(strDir2); OnOK();//关闭当前对话框(系统界面) }
[ "717977831@qq.com" ]
717977831@qq.com
76f2648cddfbf63264ecc98af30198ed42117c3b
945bd8adda2ae1ec4b8b4df44dd9b581be75a40e
/Shared/CSuperInt.h
57917778d814718383c22104fbde88064af3fcca
[]
no_license
Atrix256/SuperComp
97c908dd3ee3e9471c4f7d0c624fd86548116334
3f8e7a73ad9de276be0824251d344a965a26e13b
refs/heads/master
2021-05-01T01:20:23.661792
2016-04-21T03:26:59
2016-04-21T03:26:59
43,408,905
0
0
null
null
null
null
UTF-8
C++
false
false
13,281
h
//================================================================================= // // CSuperInt // // A superpositional integer, made up of a collection of superpositional bits. // Uses two's complement. // //================================================================================= #pragma once #include <vector> #include <array> #include <memory> #include "Macros.h" #include "CKeySet.h" #include "TINT.h" //================================================================================= template <size_t NUMBITS> class CSuperInt { public: // initialize to zero CSuperInt (const std::shared_ptr<CKeySet> &keySet) : m_keySet(keySet) { static_assert(NUMBITS > 0, "NUMBITS must be greater than 0"); std::fill(m_bits.begin(), m_bits.end(), 0); } // initialize to a non superpositional value CSuperInt (int value, const std::shared_ptr<CKeySet> &keySet) : m_keySet(keySet) { static_assert(NUMBITS > 0, "NUMBITS must be greater than 0"); SetInt(value); } // initialize to a range of a vector of superpositional bits CSuperInt ( std::vector<TINT>::const_iterator &bitsBegin, const std::shared_ptr<CKeySet> &keySet) : m_keySet(keySet) { static_assert(NUMBITS > 0, "NUMBITS must be greater than 0"); for (size_t i = 0; i < NUMBITS; ++i) m_bits[i] = bitsBegin[i]; } // decode value into binary for the given key size_t DecodeBinary (const TINT& key) const { size_t result = 0; for (size_t i = 0; i < NUMBITS; ++i) { TINT value = (m_bits[i] % key) % 2; result = result | (value.convert_to<size_t>() << i); } return result; } int DecodeInt (const TINT& key) const { return IntFromBinary(DecodeBinary(key)); } // Helper functions void SetInt (int value) { Assert_(value >= c_minValue); Assert_(value <= c_maxValue); size_t binary = (size_t)value; for (size_t i = 0; i < NUMBITS; ++i, binary = binary >> 1) m_bits[i] = (binary & 1) ? 1 : 0; } void SetToBinaryMax() { for (size_t i = 0; i < NUMBITS; ++i) m_bits[i] = 1; } // shifting is way less expensive than other operations since it doesn't use logic circuits // it just moves around the internal representation of the bits void ShiftLeft (size_t amount) { if (amount == 0) return; for (size_t index = NUMBITS - 1; index >= amount; --index) m_bits[index] = m_bits[index - amount]; for (size_t index = 0; index < amount; ++index) m_bits[index] = 0; } void SignedShiftRight (size_t amount) { if (amount == 0) return; const TINT& signBit = IsNegative(); for (size_t index = 0; index < NUMBITS - amount; ++index) m_bits[index] = m_bits[index + amount]; for (size_t index = NUMBITS - amount; index < NUMBITS; ++index) m_bits[index] = signBit; } // multiply by -1. Negates the bits, then add 1 void Negate () { const CKeySet& keySet = *m_keySet; for (TINT& bit : m_bits) bit = NOT(bit, keySet); CSuperInt<NUMBITS> one(1, m_keySet); *this = *this + one; } void NegateConditional (const TINT& condition) { // To negate in two's complement, we flip the bits and then add 1. // This effectively multiplies by -1. // make the adder here in case the condition is part of this int // as is the case of when doing abs CSuperInt<NUMBITS> add(m_keySet); add.GetBit(0) = condition; // Step 1 - negate by XORing every bit against the condition bit. // AKA negate bits conditionally. for (TINT& v : m_bits) v = XOR(v, condition, *m_keySet); // Step 2 - add a number where the lowest bit is the condition bit. // AKA add 1 conditionally. CSuperInt<NUMBITS> tempTest(m_keySet); *this = *this + add; } // absolute value. Negate if the number is negative void Abs () { NegateConditional(IsNegative()); } // returns a superpositional value for whether or not this number is negative const TINT& IsNegative() const { return *m_bits.rbegin(); } // Internals Access size_t MaxError(const TINT& key) const { float maxError = 0.0f; for (size_t i = 0; i < NUMBITS; ++i) { TINT residue = GetBit(i) % key; float error = residue.convert_to<float>() / key.convert_to<float>(); if (error > maxError) maxError = error; } return size_t(maxError * 100.0f); } const TINT& GetBit(size_t i) const { return m_bits[i]; } TINT& GetBit(size_t i) { return m_bits[i]; } const std::array<TINT, NUMBITS>& GetBits () const { return m_bits; } std::array<TINT, NUMBITS>& GetBits() { return m_bits; } const std::shared_ptr<CKeySet> &GetKeySet() const { return m_keySet; } // static interface public: static int IntFromBinary (size_t n) { n = n & c_mask; if (n & c_negativeTestMask) return -(int)((n ^ c_mask) + 1); else return n; } // public constants public: static const int c_minValue = -((1 << (NUMBITS - 1))); static const int c_maxValue = (-c_minValue) - 1; static const size_t c_negativeTestMask = 1 << (NUMBITS - 1); static const size_t c_mask = (1 << NUMBITS) - 1; static const size_t c_numBits = NUMBITS; // private members private: std::array<TINT, NUMBITS> m_bits; // the superpositional bits std::shared_ptr<CKeySet> m_keySet; // the keys to decode the bits static const TINT s_zeroBit; }; template <size_t NUMBITS> const TINT CSuperInt<NUMBITS>::s_zeroBit = 0; //================================================================================= // HE operations //================================================================================= inline TINT XOR (const TINT &A, const TINT &B, const CKeySet &keySet) { TINT result = A + B; keySet.ReduceValue(TINT(result)); return result; } //================================================================================= inline TINT AND(const TINT &A, const TINT &B, const CKeySet &keySet) { TINT result = A * B; keySet.ReduceValue(result); return result; } //================================================================================= inline TINT NOT(const TINT &A, const CKeySet &keySet) { return XOR(A, TINT(1), keySet); } //================================================================================= // Math operations //================================================================================= inline TINT FullAdder(const TINT &A, const TINT &B, TINT &carryBit, const CKeySet &keySet) { // homomorphically add the encrypted bits A and B // return the single bit sum, and put the carry bit into carryBit // From http://en.wikipedia.org/w/index.php?title=Adder_(electronics)&oldid=381607326#Full_adder TINT sumBit = XOR(XOR(A, B, keySet), carryBit, keySet); carryBit = XOR(AND(A, B, keySet), AND(carryBit, XOR(A, B, keySet), keySet), keySet); return sumBit; } //================================================================================= template <size_t NUMBITS> CSuperInt<NUMBITS> operator + (const CSuperInt<NUMBITS> &a, const CSuperInt<NUMBITS> &b) { // we initialize the carry bit to 0, not a superpositional value TINT carryBit = 0; // do the adding and return the result const std::shared_ptr<CKeySet>& keySetPointer = a.GetKeySet(); const CKeySet& keySet = *keySetPointer; CSuperInt<NUMBITS> result(keySetPointer); for (size_t i = 0; i < NUMBITS; ++i) result.GetBit(i) = FullAdder(a.GetBit(i), b.GetBit(i), carryBit, keySet); return result; } //================================================================================= template <size_t NUMBITS> CSuperInt<NUMBITS> operator - (const CSuperInt<NUMBITS> &a, const CSuperInt<NUMBITS> &b) { CSuperInt<NUMBITS> negativeB(b); negativeB.Negate(); return a + negativeB; } //================================================================================= template <size_t NUMBITS> CSuperInt<NUMBITS> operator * (const CSuperInt<NUMBITS> &a, const CSuperInt<NUMBITS> &b) { // do multiplication like this: // https://en.wikipedia.org/wiki/Binary_multiplier#Multiplication_basics const std::shared_ptr<CKeySet>& keySetPointer = a.GetKeySet(); const CKeySet& keySet = *keySetPointer; CSuperInt<NUMBITS> result(keySetPointer); for (size_t i = 0; i < NUMBITS; ++i) { CSuperInt<NUMBITS> row = b; for (TINT &v : row.GetBits()) v = AND(v, a.GetBit(i), keySet); row.ShiftLeft(i); result = result + row; } return result; } //================================================================================= template <size_t NUMBITS> CSuperInt<NUMBITS> operator / (const CSuperInt<NUMBITS> &a, const CSuperInt<NUMBITS> &b) { CSuperInt<NUMBITS> Q(a.GetKeySet()); CSuperInt<NUMBITS> R(a.GetKeySet()); Divide(a, b, Q, R); return Q; } //================================================================================= template <size_t NUMBITS> CSuperInt<NUMBITS> operator % (const CSuperInt<NUMBITS> &a, const CSuperInt<NUMBITS> &b) { CSuperInt<NUMBITS> Q(a.GetKeySet()); CSuperInt<NUMBITS> R(a.GetKeySet()); Divide(a, b, Q, R); return R; } //================================================================================= template <size_t NUMBITS> TINT operator < (const CSuperInt<NUMBITS> &a, const CSuperInt<NUMBITS> &b) { CSuperInt<NUMBITS> result(a.GetKeySet()); result = a - b; return result.IsNegative(); } //================================================================================= template <size_t NUMBITS> TINT operator <= (const CSuperInt<NUMBITS> &a, const CSuperInt<NUMBITS> &b) { return NOT(a > B, *a.GetKeySet()); } //================================================================================= template <size_t NUMBITS> TINT operator > (const CSuperInt<NUMBITS> &a, const CSuperInt<NUMBITS> &b) { CSuperInt<NUMBITS> result(a.GetKeySet()); result = b - a; return result.IsNegative(); } //================================================================================= template <size_t NUMBITS> TINT operator >= (const CSuperInt<NUMBITS> &a, const CSuperInt<NUMBITS> &b) { return NOT(a < b, *a.GetKeySet()); } //================================================================================= template <size_t NUMBITS> TINT operator == (const CSuperInt<NUMBITS> &a, const CSuperInt<NUMBITS> &b) { const CKeySet& keySet = *a.GetKeySet(); TINT ANotLtB = NOT(a < b, keySet); TINT BNotLtA = NOT(b < a, keySet); return AND(ANotLtB, BNotLtA, keySet); } //================================================================================= template <size_t NUMBITS> TINT operator != (const CSuperInt<NUMBITS> &a, const CSuperInt<NUMBITS> &b) { const CKeySet& keySet = *a.GetKeySet(); TINT ALtB = a < b; TINT BLtA = b < a; return OR(ALtB, BLtA, keySet); } //================================================================================= template <size_t NUMBITS> void Divide (const CSuperInt<NUMBITS> &Nin, const CSuperInt<NUMBITS> &Din, CSuperInt<NUMBITS> &Q, CSuperInt<NUMBITS> &R) { // Unsigned integer division algorithm from here: // https://en.wikipedia.org/wiki/Division_algorithm#Integer_division_.28unsigned.29_with_remainder // making it work for signed integers here: // http://www.cs.utah.edu/~rajeev/cs3810/slides/3810-08.pdf Q.SetInt(0); R.SetInt(0); // Make N and D positive, making sure to remember what their sign used to be CSuperInt<NUMBITS> N(Nin); CSuperInt<NUMBITS> D(Din); TINT NWasNegative = N.IsNegative(); TINT DWasNegative = D.IsNegative(); N.Abs(); D.Abs(); const CKeySet& keySet = *N.GetKeySet(); for (size_t index = NUMBITS; index > 0; --index) { size_t i = index - 1; R.ShiftLeft(1); R.GetBit(0) = N.GetBit(i); // if R >= D // R = R - D // Q[i] = 1 { // if R >= D TINT RgteD = R >= D; // R = R - D CSuperInt<NUMBITS> branchlessMultiplier(N.GetKeySet()); branchlessMultiplier.GetBit(0) = RgteD; CSuperInt<NUMBITS> subtractD(D); subtractD = D * branchlessMultiplier; R = R - subtractD; // Q[i] = 1 Q.GetBit(i) = RgteD; } } // Make dividedend and remainder have same sign TINT RIsNegative = R.IsNegative(); TINT NRNegativeMismatch = XOR(NWasNegative, RIsNegative, keySet); R.NegateConditional(NRNegativeMismatch); // Make quotient negative if signs disagree TINT quotientNegative = XOR(NWasNegative, DWasNegative, keySet); Q.NegateConditional(quotientNegative); }
[ "alan.wolfe@gmail.com" ]
alan.wolfe@gmail.com
0ae8d322647b6f34f1eb875692b946b247a539c4
4b40789003643e5875f55791526247e65887bc08
/include/vulkan/vk_layer_utils.h
762b0cf09c0f36fa00e2f7deb5b6d899828dda07
[ "MIT" ]
permissive
Nebula4869/YOLOv5-ncnn-vulkan
282abdbd21980447d0d8d3ff2996361129b79c29
d8d637e546bc0f10f00a7c3bd8a44c31478fda8a
refs/heads/master
2023-09-04T20:35:47.054582
2021-11-18T06:11:23
2021-11-18T06:11:23
302,849,512
19
1
null
null
null
null
UTF-8
C++
false
false
12,152
h
/* Copyright (c) 2015-2017, 2019 The Khronos Group Inc. * Copyright (c) 2015-2017, 2019 Valve Corporation * Copyright (c) 2015-2017, 2019 LunarG, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Author: Mark Lobodzinski <mark@lunarg.com> * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> * Author: Dave Houlton <daveh@lunarg.com> */ #pragma once #include <cassert> #include <cstddef> #include <functional> #include <stdbool.h> #include <string> #include <vector> #include <set> #include "cast_utils.h" #include "vk_format_utils.h" #include "vk_layer_logging.h" #ifndef WIN32 #include <strings.h> // For ffs() #else #include <intrin.h> // For __lzcnt() #endif #ifdef __cplusplus // Traits objects to allow string_join to operate on collections of const char * template <typename String> struct StringJoinSizeTrait { static size_t size(const String &str) { return str.size(); } }; template <> struct StringJoinSizeTrait<const char *> { static size_t size(const char *str) { if (!str) return 0; return strlen(str); } }; // Similar to perl/python join // * String must support size, reserve, append, and be default constructable // * StringCollection must support size, const forward iteration, and store // strings compatible with String::append // * Accessor trait can be set if default accessors (compatible with string // and const char *) don't support size(StringCollection::value_type &) // // Return type based on sep type template <typename String = std::string, typename StringCollection = std::vector<String>, typename Accessor = StringJoinSizeTrait<typename StringCollection::value_type>> static inline String string_join(const String &sep, const StringCollection &strings) { String joined; const size_t count = strings.size(); if (!count) return joined; // Prereserved storage, s.t. we will execute in linear time (avoids reallocation copies) size_t reserve = (count - 1) * sep.size(); for (const auto &str : strings) { reserve += Accessor::size(str); // abstracted to allow const char * type in StringCollection } joined.reserve(reserve + 1); // Seps only occur *between* strings entries, so first is special auto current = strings.cbegin(); joined.append(*current); ++current; for (; current != strings.cend(); ++current) { joined.append(sep); joined.append(*current); } return joined; } // Requires StringCollection::value_type has a const char * constructor and is compatible the string_join::String above template <typename StringCollection = std::vector<std::string>, typename SepString = std::string> static inline SepString string_join(const char *sep, const StringCollection &strings) { return string_join<SepString, StringCollection>(SepString(sep), strings); } // Perl/Python style join operation for general types using stream semantics // Note: won't be as fast as string_join above, but simpler to use (and code) // Note: Modifiable reference doesn't match the google style but does match std style for stream handling and algorithms template <typename Stream, typename String, typename ForwardIt> Stream &stream_join(Stream &stream, const String &sep, ForwardIt first, ForwardIt last) { if (first != last) { stream << *first; ++first; while (first != last) { stream << sep << *first; ++first; } } return stream; } // stream_join For whole collections with forward iterators template <typename Stream, typename String, typename Collection> Stream &stream_join(Stream &stream, const String &sep, const Collection &values) { return stream_join(stream, sep, values.cbegin(), values.cend()); } typedef void *dispatch_key; static inline dispatch_key get_dispatch_key(const void *object) { return (dispatch_key) * (VkLayerDispatchTable **)object; } VK_LAYER_EXPORT VkLayerInstanceCreateInfo *get_chain_info(const VkInstanceCreateInfo *pCreateInfo, VkLayerFunction func); VK_LAYER_EXPORT VkLayerDeviceCreateInfo *get_chain_info(const VkDeviceCreateInfo *pCreateInfo, VkLayerFunction func); static inline bool IsPowerOfTwo(unsigned x) { return x && !(x & (x - 1)); } extern "C" { #endif #define VK_LAYER_API_VERSION VK_MAKE_VERSION(1, 0, VK_HEADER_VERSION) typedef enum VkStringErrorFlagBits { VK_STRING_ERROR_NONE = 0x00000000, VK_STRING_ERROR_LENGTH = 0x00000001, VK_STRING_ERROR_BAD_DATA = 0x00000002, } VkStringErrorFlagBits; typedef VkFlags VkStringErrorFlags; VK_LAYER_EXPORT void layer_debug_report_actions(debug_report_data *report_data, const VkAllocationCallbacks *pAllocator, const char *layer_identifier); VK_LAYER_EXPORT void layer_debug_messenger_actions(debug_report_data *report_data, const VkAllocationCallbacks *pAllocator, const char *layer_identifier); VK_LAYER_EXPORT VkStringErrorFlags vk_string_validate(const int max_length, const char *char_array); VK_LAYER_EXPORT bool white_list(const char *item, const std::set<std::string> &whitelist); static inline int u_ffs(int val) { #ifdef WIN32 unsigned long bit_pos = 0; if (_BitScanForward(&bit_pos, val) != 0) { bit_pos += 1; } return bit_pos; #else return ffs(val); #endif } #ifdef __cplusplus } #endif // shared_mutex support added in MSVC 2015 update 2 #if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190023918 && NTDDI_VERSION > NTDDI_WIN10_RS2 #include <shared_mutex> #endif class ReadWriteLock { private: #if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190023918 && NTDDI_VERSION > NTDDI_WIN10_RS2 typedef std::shared_mutex lock_t; #else typedef std::mutex lock_t; #endif public: void lock() { m_lock.lock(); } bool try_lock() { return m_lock.try_lock(); } void unlock() { m_lock.unlock(); } #if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190023918 && NTDDI_VERSION > NTDDI_WIN10_RS2 void lock_shared() { m_lock.lock_shared(); } bool try_lock_shared() { return m_lock.try_lock_shared(); } void unlock_shared() { m_lock.unlock_shared(); } #else void lock_shared() { lock(); } bool try_lock_shared() { return try_lock(); } void unlock_shared() { unlock(); } #endif private: lock_t m_lock; }; #if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190023918 && NTDDI_VERSION > NTDDI_WIN10_RS2 typedef std::shared_lock<ReadWriteLock> read_lock_guard_t; typedef std::unique_lock<ReadWriteLock> write_lock_guard_t; #else typedef std::unique_lock<ReadWriteLock> read_lock_guard_t; typedef std::unique_lock<ReadWriteLock> write_lock_guard_t; #endif // Limited concurrent_unordered_map that supports internally-synchronized // insert/erase/access. Splits locking across N buckets and uses shared_mutex // for read/write locking. Iterators are not supported. The following // operations are supported: // // insert_or_assign: Insert a new element or update an existing element. // insert: Insert a new element and return whether it was inserted. // erase: Remove an element. // contains: Returns true if the key is in the map. // find: Returns != end() if found, value is in ret->second. // pop: Erases and returns the erased value if found. // // find/end: find returns a vaguely iterator-like type that can be compared to // end and can use iter->second to retrieve the reference. This is to ease porting // for existing code that combines the existence check and lookup in a single // operation (and thus a single lock). i.e.: // // auto iter = map.find(key); // if (iter != map.end()) { // T t = iter->second; // ... // // snapshot: Return an array of elements (key, value pairs) that satisfy an optional // predicate. This can be used as a substitute for iterators in exceptional cases. template <typename Key, typename T, int BUCKETSLOG2 = 2, typename Hash = std::hash<Key>> class vl_concurrent_unordered_map { public: void insert_or_assign(const Key &key, const T &value) { uint32_t h = ConcurrentMapHashObject(key); write_lock_guard_t lock(locks[h].lock); maps[h][key] = value; } bool insert(const Key &key, const T &value) { uint32_t h = ConcurrentMapHashObject(key); write_lock_guard_t lock(locks[h].lock); auto ret = maps[h].insert(typename std::unordered_map<Key, T>::value_type(key, value)); return ret.second; } // returns size_type size_t erase(const Key &key) { uint32_t h = ConcurrentMapHashObject(key); write_lock_guard_t lock(locks[h].lock); return maps[h].erase(key); } bool contains(const Key &key) const { uint32_t h = ConcurrentMapHashObject(key); read_lock_guard_t lock(locks[h].lock); return maps[h].count(key) != 0; } // type returned by find() and end(). class FindResult { public: FindResult(bool a, T b) : result(a, std::move(b)) {} // == and != only support comparing against end() bool operator==(const FindResult &other) const { if (result.first == false && other.result.first == false) { return true; } return false; } bool operator!=(const FindResult &other) const { return !(*this == other); } // Make -> act kind of like an iterator. std::pair<bool, T> *operator->() { return &result; } const std::pair<bool, T> *operator->() const { return &result; } private: // (found, reference to element) std::pair<bool, T> result; }; // find()/end() return a FindResult containing a copy of the value. For end(), // return a default value. FindResult end() const { return FindResult(false, T()); } FindResult find(const Key &key) const { uint32_t h = ConcurrentMapHashObject(key); read_lock_guard_t lock(locks[h].lock); auto itr = maps[h].find(key); bool found = itr != maps[h].end(); if (found) { return FindResult(true, itr->second); } else { return end(); } } FindResult pop(const Key &key) { uint32_t h = ConcurrentMapHashObject(key); write_lock_guard_t lock(locks[h].lock); auto itr = maps[h].find(key); bool found = itr != maps[h].end(); if (found) { auto ret = std::move(FindResult(true, itr->second)); maps[h].erase(itr); return ret; } else { return end(); } } std::vector<std::pair<const Key, T>> snapshot(std::function<bool(T)> f = nullptr) const { std::vector<std::pair<const Key, T>> ret; for (int h = 0; h < BUCKETS; ++h) { read_lock_guard_t lock(locks[h].lock); for (auto j : maps[h]) { if (!f || f(j.second)) { ret.push_back(j); } } } return ret; } private: static const int BUCKETS = (1 << BUCKETSLOG2); std::unordered_map<Key, T, Hash> maps[BUCKETS]; struct { mutable ReadWriteLock lock; // Put each lock on its own cache line to avoid false cache line sharing. char padding[(-int(sizeof(ReadWriteLock))) & 63]; } locks[BUCKETS]; uint32_t ConcurrentMapHashObject(const Key &object) const { uint64_t u64 = (uint64_t)(uintptr_t)object; uint32_t hash = (uint32_t)(u64 >> 32) + (uint32_t)u64; hash ^= (hash >> BUCKETSLOG2) ^ (hash >> (2 * BUCKETSLOG2)); hash &= (BUCKETS - 1); return hash; } };
[ "nebula4869@foxmail.com" ]
nebula4869@foxmail.com
decd1647776cf5779c730b3c12684acc0ed2ba21
fab4ad6ea1b3da746056422359690824351ba07e
/CODE/public/fileconfig/CService.cpp
86d1c193dbd8ae87676177ed800e99ccd315373b
[]
no_license
hongdeyongying/lab_of_2012
455f55043513135eab556353c1655222e96ba285
e79007912615cf0f5416255c39c972d4ede24cc4
refs/heads/master
2020-05-28T10:22:15.367241
2019-07-18T01:42:28
2019-07-18T01:42:28
188,967,041
0
0
null
null
null
null
GB18030
C++
false
false
3,983
cpp
// ************************************************* // 创建日期: 2010-5-14 // 作 者:高勇 (gaussgao@tencent.com) // 主要功能: 实现xml-like配置文件的读取。 // ************************************************* #include "CService.h" static MyConfig::CVariable varBlank; static MyConfig::CVariableVector varVectorBlank; static MyConfig::CParameter paraBlank; //##ModelId=4C0F11E8030D MyConfig::CService::CService() :m_sName(""),m_sType(""),m_sDesc("") { m_mvParameter.clear(); m_mvVariable.clear(); } //##ModelId=4C0F11E8034B MyConfig::CService::~CService() { } //##ModelId=4C0F33A302EE MyConfig::CService::CService(const std::string &inName, const std::string &inType, const std::string &inDesc) :m_sName(inName),m_sType(inType),m_sDesc(inDesc) { m_mvParameter.clear(); m_mvVariable.clear(); } //##ModelId=4C0F342B02DA const std::string &MyConfig::CService::GetVarVal(const std::string &inName) const { const MyConfig::CVariable *res = &varBlank; MyConfig::CVariableVectorMap::const_iterator iter = m_mvVariable.find(inName); if(m_mvVariable.end() != iter ) { if(iter->second.size() != 0) res = &iter->second.at(0); } return res->GetValue(); } //##ModelId=4C0F347F007D const MyConfig::CParameter &MyConfig::CService::GetParaObj(const std::string &inName) const { const MyConfig::CParameter * res =&paraBlank; MyConfig::CParameterVectorMap::const_iterator iter = m_mvParameter.find(inName); if(m_mvParameter.end() != iter ) { if(iter->second.size() != 0) res = &iter->second.at(0); } return *res; } //##ModelId=4C0F34B900C3 const MyConfig::CVariable &MyConfig::CService::GetVarObj(const std::string &inName) const { const MyConfig::CVariable *res = &varBlank; MyConfig::CVariableVectorMap::const_iterator iter = m_mvVariable.find(inName); if(m_mvVariable.end() != iter ) { if(iter->second.size() != 0) res = &iter->second.at(0); } return *res; } const MyConfig::CVariableVector &MyConfig::CService::GetVarVectorObj(const std::string &inName) const { const MyConfig::CVariableVector *res = &varVectorBlank; MyConfig::CVariableVectorMap::const_iterator iter = m_mvVariable.find(inName); if(m_mvVariable.end() != iter ) { if(iter->second.size() != 0) res = &iter->second; } return *res; } //##ModelId=4C0F39E90284 std::string const& MyConfig::CService::GetDesc() const { return m_sDesc; } //##ModelId=4C0F39E902D3 void MyConfig::CService::SetDesc(std::string& left) { m_sDesc = left; } //##ModelId=4C0F39E9038E std::string const& MyConfig::CService::GetName() const { return m_sName; } //##ModelId=4C0F39E903DC void MyConfig::CService::SetName(std::string& left) { m_sName = left; } //##ModelId=4C0F39EA00BF std::string const& MyConfig::CService::GetType() const { return m_sType; } //##ModelId=4C0F39EA011D void MyConfig::CService::SetType(std::string& left) { m_sType = left; } /* //##ModelId=4C0F39FD0043 const MyConfig::CParameterMap & MyConfig::CService::GetParameterMap() const { return m_mParameter; } //##ModelId=4C0F39FD00B0 const MyConfig::CVariableMap & MyConfig::CService::GetVariableMap() const { return m_mVariable; } //##ModelId=4C0F39FD0043 MyConfig::CParameterMap & MyConfig::CService::GetParameterMap() { return m_mParameter; } //##ModelId=4C0F39FD00B0 MyConfig::CVariableMap & MyConfig::CService::GetVariableMap() { return m_mVariable; } //*/ const MyConfig::CParameterVectorMap & MyConfig::CService::GetParameterVectorMap() const { return m_mvParameter; } //##ModelId=4C0F39FD00B0 const MyConfig::CVariableVectorMap & MyConfig::CService::GetVariableVectorMap() const { return m_mvVariable; } //##ModelId=4C0F39FD0043 MyConfig::CParameterVectorMap & MyConfig::CService::GetParameterVectorMap() { return m_mvParameter; } //##ModelId=4C0F39FD00B0 MyConfig::CVariableVectorMap & MyConfig::CService::GetVariableVectorMap() { return m_mvVariable; }
[ "gaoyong@wucar.com.cn" ]
gaoyong@wucar.com.cn
7c8b7593e8816b469099bc0343082f708084bca6
5456502f97627278cbd6e16d002d50f1de3da7bb
/chromeos/network/firewall_hole_unittest.cc
66954a49728c5f40892683b7486c6a1cf8edd819
[ "BSD-3-Clause" ]
permissive
TrellixVulnTeam/Chromium_7C66
72d108a413909eb3bd36c73a6c2f98de1573b6e5
c8649ab2a0f5a747369ed50351209a42f59672ee
refs/heads/master
2023-03-16T12:51:40.231959
2017-12-20T10:38:26
2017-12-20T10:38:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,469
cc
// Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chromeos/network/firewall_hole.h" #include "base/bind.h" #include "base/memory/ptr_util.h" #include "base/run_loop.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/mock_permission_broker_client.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" using chromeos::DBusThreadManager; using chromeos::FirewallHole; using chromeos::MockPermissionBrokerClient; using testing::_; namespace { ACTION_TEMPLATE(InvokeCallback, HAS_1_TEMPLATE_PARAMS(int, k), AND_1_VALUE_PARAMS(p1)) { ::std::tr1::get<k>(args).Run(p1); } } // namespace class FirewallHoleTest : public testing::Test { public: FirewallHoleTest() {} ~FirewallHoleTest() override {} void SetUp() override { mock_permission_broker_client_ = new MockPermissionBrokerClient(); DBusThreadManager::GetSetterForTesting()->SetPermissionBrokerClient( base::WrapUnique(mock_permission_broker_client_)); } void TearDown() override { DBusThreadManager::Shutdown(); } void AssertOpenSuccess(std::unique_ptr<FirewallHole> hole) { EXPECT_TRUE(hole.get() != nullptr); run_loop_.Quit(); } void AssertOpenFailure(std::unique_ptr<FirewallHole> hole) { EXPECT_TRUE(hole.get() == nullptr); run_loop_.Quit(); } private: base::MessageLoopForUI message_loop_; protected: base::RunLoop run_loop_; MockPermissionBrokerClient* mock_permission_broker_client_ = nullptr; }; TEST_F(FirewallHoleTest, GrantTcpPortAccess) { EXPECT_CALL(*mock_permission_broker_client_, RequestTcpPortAccess(1234, "foo0", _, _)) .WillOnce(InvokeCallback<3>(true)); EXPECT_CALL(*mock_permission_broker_client_, ReleaseTcpPort(1234, "foo0", _)) .WillOnce(InvokeCallback<2>(true)); FirewallHole::Open( FirewallHole::PortType::TCP, 1234, "foo0", base::Bind(&FirewallHoleTest::AssertOpenSuccess, base::Unretained(this))); run_loop_.Run(); } TEST_F(FirewallHoleTest, DenyTcpPortAccess) { EXPECT_CALL(*mock_permission_broker_client_, RequestTcpPortAccess(1234, "foo0", _, _)) .WillOnce(InvokeCallback<3>(false)); FirewallHole::Open( FirewallHole::PortType::TCP, 1234, "foo0", base::Bind(&FirewallHoleTest::AssertOpenFailure, base::Unretained(this))); run_loop_.Run(); } TEST_F(FirewallHoleTest, GrantUdpPortAccess) { EXPECT_CALL(*mock_permission_broker_client_, RequestUdpPortAccess(1234, "foo0", _, _)) .WillOnce(InvokeCallback<3>(true)); EXPECT_CALL(*mock_permission_broker_client_, ReleaseUdpPort(1234, "foo0", _)) .WillOnce(InvokeCallback<2>(true)); FirewallHole::Open( FirewallHole::PortType::UDP, 1234, "foo0", base::Bind(&FirewallHoleTest::AssertOpenSuccess, base::Unretained(this))); run_loop_.Run(); } TEST_F(FirewallHoleTest, DenyUdpPortAccess) { EXPECT_CALL(*mock_permission_broker_client_, RequestUdpPortAccess(1234, "foo0", _, _)) .WillOnce(InvokeCallback<3>(false)); FirewallHole::Open( FirewallHole::PortType::UDP, 1234, "foo0", base::Bind(&FirewallHoleTest::AssertOpenFailure, base::Unretained(this))); run_loop_.Run(); }
[ "lixiaodonglove7@aliyun.com" ]
lixiaodonglove7@aliyun.com
0ffc4b1e52e7dff21526419aeb93a5b6f88713aa
0de01aa2c12704a893ad0e14db6df5caa774b519
/5/Fourteens.cpp
b8df35f60e8e694445d85dbfec8a9592768654da
[]
no_license
baifengbai/learningCplusplus
4fda87351c5400dec92167eafa4db282db666466
95a8dd8ea842051d6a631d959030b6e69195d347
refs/heads/master
2020-03-20T21:13:48.617533
2017-03-01T16:04:28
2017-03-01T16:04:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
290
cpp
#include <iostream> int main() { int counter = 0; int multiples = 0; while (true) { counter++; if (counter % 14 == 0) { std::cout << counter << " "; multiples++; } if (multiples > 19) { break; } } std::cout << "\n"; return 0; }
[ "liz@lizbaillie.com" ]
liz@lizbaillie.com
8a430b53d089cd4fda40c5006c567aa0dbb3800f
193f6b964b1a030d1e819ca4932fb2b829e2e41c
/DX11_1908/Objects/Particle/Spark.h
089cc548de37493be35757e4cedcfbb47f368d53
[]
no_license
fkem79/DX11_Team_HomeSweetHome
cef13f869bee16fb2bbfe401364a2d4293925b2f
27b5b45ddcaaa407eb7e385f0ac63bdbd75c46e2
refs/heads/master
2021-05-18T20:34:29.754175
2020-05-10T16:37:20
2020-05-10T16:37:20
251,392,881
1
0
null
2020-05-08T12:57:25
2020-03-30T18:25:32
C++
UTF-8
C++
false
false
932
h
#pragma once #include "Particle.h" class Spark : public Particle { private: struct VertexParticle { Float3 position; Float2 size; Float3 velocity; }; class SparkBuffer : public ConstBuffer { public: struct Data { float duration; float time; float gravity; float padding; }data; SparkBuffer() : ConstBuffer(&data, sizeof(Data)) { data.duration = 0.0f; data.time = 0.0f; data.gravity = 0.0f; } }; class ColorBuffer : public ConstBuffer { public: struct Data { Float4 start; Float4 end; }data; ColorBuffer() : ConstBuffer(&data, sizeof(Data)) { data.start = Float4(1, 0, 0, 1); data.end = Float4(1, 1, 0, 0.2f); } }; SparkBuffer* sparkBuffer; ColorBuffer* colorBuffer; vector<VertexParticle> vertices; public: Spark(); ~Spark(); void Update() override; void Render() override; void Play(Vector3 position) override; void Create() override; };
[ "fkemless79@mju.ac.kr" ]
fkemless79@mju.ac.kr
67241fbf5181a8b0f1ef63987284aa01ad14bde0
d5e07d17d0947a3f4e17dbb0fb3574fb022727fe
/Module 6: Binary Trees/06 Challenge: Binary Tree Functions/main.cpp
d67fa0295fec50795a404bb76f298b84dcd3bfc8
[]
no_license
Bradon-Barfuss/CS-2420-Advance-Data-Structures
c7dc31a05be235a340296e2cd02ae022338baea5
bc0aa58a3bc0f125543986b1192c2750768c0332
refs/heads/master
2022-06-11T04:46:05.513240
2020-05-08T00:49:31
2020-05-08T00:49:31
258,636,363
0
0
null
null
null
null
UTF-8
C++
false
false
3,366
cpp
#include <iostream> #include <string> #include <memory> #include "BinaryTree.h" using namespace std; bool checkTest(string testName, bool condition); bool checkTest(string testName, int whatItShouldBe, int whatItIs); void testFindMethod(); void testRightMostNodeSearch(); void deleteTest(); void testHeight(); void testLeavesCount(); BinaryTree<int> populateTree(); int main() { BinaryTree<int> myTree = populateTree(); myTree.inOrder(); cout << endl; testFindMethod(); testRightMostNodeSearch(); deleteTest(); testHeight(); testLeavesCount(); cout << "Completed the Program" << endl; return 0; } BinaryTree <int> populateTree(){ BinaryTree<int> myTree; int values[] = {37, 32, 73, 95, 42, 12, 0, 49, 98, 7, 27, 17, 47, 87, 77, 97, 67, 85, 15, 5, 35, 55, 65, 75, 25, 45, 3, 93, 83, 53, 63, 23, 13, 43, 33}; int size = (sizeof(values)/sizeof(*values)); for(int i = 0; i < size; i++){ myTree.insert(values[i]); } return myTree; } void testFindMethod( ){ BinaryTree<int> myTree = populateTree(); auto ptr = myTree.find(49); checkTest("Test 1: Find(49)", 49, ptr->item); ptr = myTree.find(200); checkTest("Test 2: Find(200)", ptr == nullptr); } void testRightMostNodeSearch(){ BinaryTree<int> myTree = populateTree(); auto ptr = myTree.find(49); auto ptrchild = myTree.findRightMostNode(ptr); checkTest("Test 3: RightNodeTest(49)", 67, ptrchild->item); } void deleteTest(){ BinaryTree<int> myTree = populateTree(); myTree.remove(35); auto ptr = myTree.find(35); if(!checkTest("Test 4: Delete Leaf: 13", ptr == nullptr)){ cout << "In Order: "; myTree.inOrder(); cout << endl; } myTree.remove(67); ptr = myTree.find(67); if(!checkTest("Test 5: Delete Node with Left Child: 67", ptr == nullptr)){ cout << "In Order: "; myTree.inOrder(); cout << endl; } myTree.remove(42); ptr = myTree.find(42); if(!checkTest("Test 6: Delete Node with Right Child: 42", ptr == nullptr)){ cout << "In Order: "; myTree.inOrder(); cout << endl; } myTree.remove(73); ptr = myTree.find(73); if(!checkTest("Test 7: Delete Node with two children: 42", ptr == nullptr)){ cout << "In Order: "; myTree.inOrder(); cout << endl; } myTree.remove(37); ptr = myTree.find(37); if(!checkTest("Test 8: Delete root: 37", ptr == nullptr)){ cout << "In Order: "; myTree.inOrder(); cout << endl; } } void testHeight(){ BinaryTree<int> myTree = populateTree(); cout << myTree.height(); checkTest("Test 9: height()", 6 == myTree.height()); } void testLeavesCount(){ BinaryTree<int> myTree = populateTree(); checkTest("Test 10: leavesCount()", 11 == myTree.leavesCount()); } //Helps with Testing bool checkTest(string testName, int whatItShouldBe, int whatItIs) { if (whatItShouldBe == whatItIs) { cout << "Passed " << testName << endl; return true; } else { cout << "***Failed test " << testName << " *** " << endl << " Output was " << whatItIs << endl << " Output should have been " << whatItShouldBe << endl; return false; } } //Helps with Testing bool checkTest(string testName, bool condition) { if (condition) { cout << "Passed " << testName << endl; return true; } else { cout << "***Failed test " << testName << " *** " << endl; return false; } }
[ "noreply@github.com" ]
noreply@github.com
ad05f22d3bcc9b57e41574cd25b46e96478c84c4
748af756401482fffa192316daa9106a64d58c1b
/MOTORES.ino
58a75d13e1b5fe35fd9a73df930c9d34ef5eb2bd
[]
no_license
AlanAlvarez21/projecto-mano-
8b50b792dc0f99f55dade18c4952368bc54867cb
6f5b58995487c47834c2a5103ba837342ab15840
refs/heads/master
2023-02-20T20:01:11.260719
2021-01-28T06:01:59
2021-01-28T06:01:59
333,639,260
1
0
null
null
null
null
UTF-8
C++
false
false
2,917
ino
#include <PIDController.h> #include <EEPROM.h> volatile long int encoder_pos =0 ,encoder_pos1 = 0; PIDController pos_pid; PIDController pos1_pid; int motor_value = 255; #define EEPROM_SIZE 1 int lastpost=0,lastpost1=0; unsigned int integerValue=0; // Max value is 65535 char incomingByte; void setup() { Serial.begin(9600); leer(); // EEPROM.begin(EEPROM_SIZE); pinMode(2, INPUT);// c1 m1 pinMode(3, INPUT);//c2 m2 pinMode(4, INPUT);// posicion pinMode(5, INPUT);// posicion pinMode(9, OUTPUT); pinMode(10, OUTPUT); pinMode(11, OUTPUT); pinMode(6, OUTPUT); attachInterrupt(digitalPinToInterrupt(2), encoder, RISING); attachInterrupt(digitalPinToInterrupt(3), encoder1, RISING); pos_pid.begin(); pos_pid.tune(15, 1, 2000); // pos_pid.limit(-255, 255); pos1_pid.begin(); pos1_pid.tune(15, 1, 2000); pos1_pid.limit(-255, 255); } void loop() { if (Serial.available() > 0) { integerValue = 0; while(1) { incomingByte = Serial.read(); if (incomingByte == '\n') break; if (incomingByte == -1) continue; integerValue *= 10; integerValue = ((incomingByte - 48) + integerValue); pos_pid.setpoint(integerValue); pos1_pid.setpoint(integerValue); } } motor_value = pos_pid.compute(encoder_pos); if(motor_value > 0){ MotorCounterClockwise(motor_value); }else{ MotorClockwise(abs(motor_value)); } motor_value = pos1_pid.compute(encoder_pos1); if(motor_value > 0){ MotorCounterClockwise1(motor_value); }else{ MotorClockwise1(abs(motor_value)); } EEPROM.write(0,encoder_pos); EEPROM.write(1,encoder_pos1); Serial.println((String)encoder_pos+","+(String)encoder_pos1); // Serial.println(","); // Serial.println(encoder_pos1); delay(10); } void epromsisa() { EEPROM.write(0,encoder_pos); EEPROM.write(1,encoder_pos1); } void leer() { pos_pid.setpoint(EEPROM.read(0)); pos1_pid.setpoint(EEPROM.read(1)); } void encoder1(){ if(digitalRead(5) == HIGH){ encoder_pos1++; }else{ encoder_pos1--; } } void encoder(){ if(digitalRead(4) == HIGH){ encoder_pos++; }else{ encoder_pos--; } } void MotorClockwise(int power){ if(power > 100){ analogWrite(9, power); digitalWrite(10, LOW); }else{ digitalWrite(9, LOW); digitalWrite(10, LOW); } } void MotorClockwise1(int power){ if(power > 100){ analogWrite(6, power); digitalWrite(11, LOW); }else{ digitalWrite(6, LOW); digitalWrite(11, LOW); } } void MotorCounterClockwise(int power){ if(power > 100){ analogWrite(10, power); digitalWrite(9, LOW); }else{ digitalWrite(9, LOW); digitalWrite(10, LOW); } } void MotorCounterClockwise1(int power){ if(power > 100){ analogWrite(11, power); digitalWrite(6, LOW); }else{ digitalWrite(6, LOW); digitalWrite(11, LOW); } }
[ "olin@Olin-Cacas" ]
olin@Olin-Cacas
cb0b9b22bd97c946ecd02e9baf5959e2cb9d9a91
091137901d29704d753d0a493c74e7863cb5ef25
/src/Evento.hpp
7cd3441dadcc52978afdded527e92d77a1da36ec
[]
no_license
spimpaov/Simulador-AD
dd5ed0dcfa372f7357b5331965c28f5d8466638a
ea4b5f049c4ec78b7f39b7198c7f6b1cf7a78f23
refs/heads/master
2020-08-01T21:17:31.276452
2019-07-12T10:34:06
2019-07-12T10:34:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
589
hpp
#ifndef EVENTO #define EVENTO #include<iostream> //Temos dois tipos de eventos: A chegada na fila e a saída da fila enum class TipoEvento{ CHEGADA, SAIDA }; class Evento { public: //Tempo em que o evento ocorreu double TempoOcorrencia; TipoEvento Tipo; Evento(TipoEvento tipoEvento, double tempo); //Operador para definir qual evento ocorre antes, usado para ordenação da heap de eventos friend bool operator<(Evento evento1, Evento evento2); friend std::ostream& operator<<(std::ostream& os, const Evento& evento); }; #endif
[ "lucascmgsds@gmail.com" ]
lucascmgsds@gmail.com
3f792fd94ce2b30913a9f48d2341f1fe4bf6aa0d
dadb31512584bdd65f4cd4b2810b0775e2e3cfae
/engine/renderers/opengl/OpenGLMaterial.h
e78342727fa7f8510457024682c2994328e704d4
[ "Apache-2.0" ]
permissive
fromasmtodisasm/AeonEngine
c1796d70bc44a5073c4c4b623ab7db416cbf85c3
bb872e66ba76de41980d19c70becc8988d5b7490
refs/heads/master
2023-03-20T17:00:30.016264
2021-03-15T17:55:32
2021-03-15T18:03:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,683
h
/* Copyright (C) 2016-2019 Rodrigo Jose Hernandez Cordoba Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #ifndef AEONGAMES_OPENGLMATERIAL_H #define AEONGAMES_OPENGLMATERIAL_H #include <cstdint> #include <string> #include <vector> #include <tuple> #include <memory> #include "aeongames/Material.h" #include "aeongames/Vector2.h" #include "aeongames/Vector3.h" #include "aeongames/Vector4.h" #include "OpenGLBuffer.h" namespace AeonGames { class OpenGLRenderer; class OpenGLTexture; class OpenGLMaterial : public Material { public: OpenGLMaterial ( uint32_t aPath = 0 ); OpenGLMaterial ( std::initializer_list<UniformKeyValue> aUniforms, std::initializer_list<SamplerKeyValue> aSamplers ); /// The Copy Contsructor is used for virtual copying. OpenGLMaterial ( const OpenGLMaterial& aMaterial ); /// Assignment operator due to rule of zero/three/five. OpenGLMaterial& operator= ( const OpenGLMaterial& aMaterial ); /// No move assignment allowed OpenGLMaterial& operator = ( OpenGLMaterial&& ) = delete; /// No move allowed OpenGLMaterial ( OpenGLMaterial&& ) = delete; ~OpenGLMaterial() final; /// @copydoc Material::Clone() std::unique_ptr<Material> Clone() const final; ///@name Loaders ///@{ void Load ( const MaterialBuffer& aMaterialBuffer ) final; void Load ( std::initializer_list<UniformKeyValue> aUniforms, std::initializer_list<SamplerKeyValue> aSamplers ) final; void Unload() final; ///@} ///@name Property and Sampler Setters ///@{ void Set ( size_t aIndex, const UniformValue& aValue ) final; void Set ( const UniformKeyValue& aValue ) final; void SetSampler ( const std::string& aName, const ResourceId& aValue ) final; ///@} ///@name Property and Sampler Getters ///@{ ResourceId GetSampler ( const std::string& aName ) final; const std::vector<std::tuple<std::string, ResourceId>>& GetSamplers() const final; ///@} GLuint GetPropertiesBufferId() const; private: OpenGLBuffer mUniformBuffer{}; }; } #endif
[ "kwizatz@aeongames.com" ]
kwizatz@aeongames.com
78359cff351acbd10a83e950c1cd71d79e696b7d
3f370809633ba7914212247bd5bb3d6800481949
/source/common/http/http2/metadata_encoder.h
e1d249c33d8a88504476f4a3d681a9e7e249e0d6
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
aschran/envoy
166290b4fd7c820ebf53d437b8ccf4b1567521b5
40b5f2ec4e202ac7607405e4785b0afe495ca320
refs/heads/master
2020-04-02T19:32:35.557115
2018-10-25T22:32:44
2018-10-25T22:32:44
154,737,561
1
0
Apache-2.0
2018-10-25T21:05:37
2018-10-25T21:05:37
null
UTF-8
C++
false
false
2,747
h
#pragma once #include <cstdint> #include <string> #include "common/buffer/buffer_impl.h" #include "common/common/logger.h" #include "common/http/http2/metadata_interface.h" #include "nghttp2/nghttp2.h" namespace Envoy { namespace Http { namespace Http2 { /** * A class that creates and sends METADATA payload. The METADATA payload is a group of string key * value pairs encoded in HTTP/2 header blocks. */ class MetadataEncoder : Logger::Loggable<Logger::Id::http2> { public: MetadataEncoder(uint64_t stream_id); /** * Creates wire format HTTP/2 header block from metadata_map. Only after previous payload is * drained, new payload can be encoded. This limitation is caused by nghttp2 can't incrementally * encode header block. * @param metadata_map supplies METADATA to encode. * @return whether encoding is successful. */ bool createPayload(MetadataMap& metadata_map); /** * Called in nghttp2 callback function after METADATA is submitted. The function releases len data * in payload_. * @param len supplies the size to be released. */ void releasePayload(uint64_t len); /** * @return true if there is payload to be submitted. */ bool hasNextFrame(); /** * Returns payload to be submitted. * @return the reference to payload. */ Buffer::OwnedImpl& payload() { return payload_; } /** * TODO(soya3129): move those functions to MetadataHandler, since it's session level parameter. * Set max payload size for METADATA frame. * @param size supplies max frame size. */ void setMaxMetadataSize(size_t size) { max_frame_size_ = size; } /** * Get max payload size for METADATA frame. * @return max frame size. */ uint64_t getMaxMetadataSize() { return max_frame_size_; } private: /** * Creates wired format header blocks using nghttp2. * @param metadata_map supplies METADATA to encode. * @return true if the creation succeeds. */ bool createHeaderBlockUsingNghttp2(MetadataMap& metadata_map); // The METADATA payload to be sent. Buffer::OwnedImpl payload_; // Max payload size for METADATA frame. uint64_t max_frame_size_ = 16384; // Max payload size bound. const uint64_t max_payload_size_bound_ = 1024 * 1024; // The stream id the encoder is associated with. const uint64_t stream_id_; // Default HPACK table size. const size_t header_table_size_ = 4096; // TODO(soya3129): share deflater among all encoders in the same connection. The benefit is less // memory, and the caveat is encoding error on one stream can impact other streams. typedef CSmartPtr<nghttp2_hd_deflater, nghttp2_hd_deflate_del> Deflater; Deflater deflater_; }; } // namespace Http2 } // namespace Http } // namespace Envoy
[ "mklein@lyft.com" ]
mklein@lyft.com
33de8e5036b10868963ff5923f5d8e563a5d6851
f73092776c4481a2a9705eac4ca7d48447d33f77
/src/getuntil.cpp
69c2e1dd4f368fbd7309db3f5758c4c6956ef627
[]
no_license
oki-miyuki/pop3lib
51348418492b051bb18890a6de4004e31eeb6817
bbd1d988672754dc08509f93f58b49fa27040b8f
refs/heads/master
2020-05-23T08:11:00.844145
2016-10-08T02:16:36
2016-10-08T02:16:36
70,296,765
0
0
null
null
null
null
UTF-8
C++
false
false
1,474
cpp
// // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // // Copyright (c) 2007-2009 OKI Miyuki (oki.miyuki at gmail dot com) // //--------------------------------------------------------------------------- // sample of getuntil.hpp //--------------------------------------------------------------------------- #include "getuntil.hpp" #include <fstream> #include <sstream> #include <iomanip> #include <boost/asio.hpp> int main() { std::ifstream ifs( "src/getuntil.cpp", std::ios::binary ); int i = 0; std::string delm( "\r\n" ); std::string line; while( ifs.good() ) { getuntil( ifs, line, delm ); std::cout << std::setw(3) << ++i << ": " << line; } std::cout << std::endl; std::cout << "Enter stringstream test" << std::endl; std::stringstream ss; ss << "hi-ho, hi-ho!"; ss << "It's home from work we go! hi-ho, hi-ho!..."; while( ss.good() ) { getuntil( ss, line, "ho!" ); std::cout << line << std::endl; } std::cout << std::endl; std::cout << "Enter boost::asio::streambuf test" << std::endl; boost::asio::streambuf sb; std::ostream ostrm( &sb ); ostrm << "This is data from client\r\n"; ostrm << "And flying send\r\n"; std::istream istrm( &sb ); while( istrm.good() ) { getuntil( istrm, line, "\r\n" ); std::cout << line; } }
[ "oki.miyuki@gmail.com" ]
oki.miyuki@gmail.com
e101f870f06ace504e831212bb7a67f15ce37918
4059c61ec0d96e66c4bb8ef8b9f5596bf3772ffa
/src/OPSLC/DescriptorSetParser.h
6f5c7565a7b500f0e91cd1aae2de2f80e5ccf07c
[]
no_license
JeremiahGilbert/OPSLC
49d5676d705bc1df7d47d4f15e008fac722dce67
aee3b8ff4fdbaa6cd4baacfbaefdf14494378873
refs/heads/master
2023-04-02T13:18:52.474652
2021-03-18T23:01:52
2021-03-18T23:01:52
251,085,619
0
0
null
null
null
null
UTF-8
C++
false
false
651
h
#pragma once #include <vulkan/vulkan.hpp> #include "opsl.h" #include "GLSLTypes.h" #include "ParserTypes.h" class DescriptorSetParser { public: void operator()(InitDeclaratorList const& init_declarator_list, vk::ShaderStageFlagBits const stage_flags, GLSLTypes const& glsl_types); void operator()(InterfaceBlock const& interface_block, vk::ShaderStageFlagBits const stage_flags, GLSLTypes const& glsl_types); inline opsl::DescriptorSetLayoutBindings get_descriptor_set_layout_bindings() const { return descriptor_set_layout_bindings_; } private: uint32_t binding_; opsl::DescriptorSetLayoutBindings descriptor_set_layout_bindings_; };
[ "oathtakerpaladin@gmail.com" ]
oathtakerpaladin@gmail.com
7315d71d9fd09607e80ae3f6e6e239167417715f
fb7efe44f4d9f30d623f880d0eb620f3a81f0fbd
/chrome/browser/safe_browsing/incident_reporting/resource_request_detector.h
219054c07f76c73a65a5e032ed46237ec7d50dd6
[ "BSD-3-Clause" ]
permissive
wzyy2/chromium-browser
2644b0daf58f8b3caee8a6c09a2b448b2dfe059c
eb905f00a0f7e141e8d6c89be8fb26192a88c4b7
refs/heads/master
2022-11-23T20:25:08.120045
2018-01-16T06:41:26
2018-01-16T06:41:26
117,618,467
3
2
BSD-3-Clause
2022-11-20T22:03:57
2018-01-16T02:09:10
null
UTF-8
C++
false
false
2,114
h
// Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_RESOURCE_REQUEST_DETECTOR_H_ #define CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_RESOURCE_REQUEST_DETECTOR_H_ #include <memory> #include "base/containers/hash_tables.h" #include "base/macros.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.h" #include "components/safe_browsing/db/database_manager.h" namespace net { class URLRequest; } namespace safe_browsing { class ClientIncidentReport_IncidentData_ResourceRequestIncident; struct ResourceRequestInfo { GURL url; content::ResourceType resource_type; int render_process_id; int render_frame_id; }; // Observes network requests and reports suspicious activity. class ResourceRequestDetector { public: static ResourceRequestInfo GetRequestInfo(const net::URLRequest* request); ResourceRequestDetector( scoped_refptr<SafeBrowsingDatabaseManager> sb_database_manager, std::unique_ptr<IncidentReceiver> incident_receiver); ~ResourceRequestDetector(); // Analyzes the |request| and triggers an incident report on suspicious // script inclusion. void ProcessResourceRequest(const ResourceRequestInfo* request); protected: // Testing hook. void set_allow_null_profile_for_testing(bool allow_null_profile_for_testing); private: void ReportIncidentOnUIThread( int render_process_id, int render_frame_id, std::unique_ptr<ClientIncidentReport_IncidentData_ResourceRequestIncident> incident_data); std::unique_ptr<IncidentReceiver> incident_receiver_; scoped_refptr<SafeBrowsingDatabaseManager> database_manager_; bool allow_null_profile_for_testing_; base::WeakPtrFactory<ResourceRequestDetector> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(ResourceRequestDetector); }; } // namespace safe_browsing #endif // CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_RESOURCE_REQUEST_DETECTOR_H_
[ "jacob-chen@iotwrt.com" ]
jacob-chen@iotwrt.com
ad728b4d87eafed434b5e3881f5a7b6cc58a3fd9
b5b56ce3eb1dfe324eafbda3e0e5f338c5dd72e2
/Server/Servers/include/CategoryTreeRegionConfiguration.h
6a3d62f9154f7a94abeef52bdad2cec912436c1b
[]
no_license
wayfinder/Wayfinder-Server
5cb91281b33cea6d8f6d74550b6564a71c4be1d7
a688546589f246ee12a8a167a568a9c4c4ef8151
refs/heads/master
2021-01-22T22:39:08.348787
2012-03-31T11:34:42
2012-03-31T11:34:42
727,490
8
1
null
null
null
null
UTF-8
C++
false
false
4,481
h
/* Copyright (c) 1999 - 2010, Vodafone Group Services Ltd All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Vodafone Group Services Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef CATEGORY_TREE_REGION_CONFIGURATION_H #define CATEGORY_TREE_REGION_CONFIGURATION_H #include "config.h" #include "MC2String.h" #include "CategoryTree.h" #include "CategoryRegionID.h" #include <boost/shared_ptr.hpp> #include <vector> #include <map> namespace CategoryTreeUtils { /** * Contains a region specific configuration for a category tree. * A RegionConfiguration object is used together with a * CategoryTree object containing the full tree in order to create a new * CategoryTree object for a specific region. */ class RegionConfiguration { private: /// Container for category information. typedef std::pair< bool, MC2String > CategoryPair; /// Map for CategoryID and information about the category. typedef std::map< CategoryID, CategoryPair > CategoryConfigMap; public: /// Vector with icon information for the categories. typedef std::vector< std::pair <CategoryID, MC2String> > IconInfo; public: /** * Creates an empty configuration. */ RegionConfiguration(); /** * Destructor */ virtual ~RegionConfiguration(); /** * Adds a category that should be included in the tree. */ void addCategory( CategoryID categoryId, bool isVisible, const MC2String& icon); /** * @param category The category to check for inclusion. * @return Whether this region includes the category. */ bool isCategoryVisible( CategoryID categoryId ) const; /** * @param category The category to get the icon for. * @return The icon to use for the category in this region. * Empty string if no region configured exist. */ void getCategoryIcons( IconInfo& info ) const; private: /** * Map for holding category information */ CategoryConfigMap m_categoryConfig; }; // class RegionConfiguration // Typedefs for RegionConfigurations typedef boost::shared_ptr<RegionConfiguration> RegionConfigSharedPtr; typedef std::pair< CategoryRegionID, RegionConfigSharedPtr > CategoryRegionConfiguration; typedef std::vector< CategoryRegionConfiguration > RegionConfigurations; /** * Loads all the region specific settings from one file into different * RegionConfiguration objects. * @return A pointer to the configuration for all the regions. * NULL if configuration invalid or missing. */ RegionConfigurations* loadRegionConfigurations( const MC2String& regionConfigPath ); /** * Applies region specific settings to a full category tree, producing * a new tree conforming to the settings. * * @param tree The full tree. * @param config Configuration for the region. * @throw MC2Exception if some icons aren't available on disc. */ CategoryTree* applyRegionConfiguration( const CategoryTree* tree, const RegionConfiguration& config ); } // namespace CategoryTreeUtils #endif
[ "daniel.n.pettersson@gmail.com" ]
daniel.n.pettersson@gmail.com
fe58735eb35ce69f883c64bc37fdfcffc8f4e417
3055d7ddce40025d1d4d98129c2641fd80f82afb
/dripping/system/decomposeParDict
41fa2d8ef8e83d5e0b2aeebdd6dd279ede417523
[]
no_license
ptorres-uom/rheoInterFoam-drippingBUG
02eb7ab6271579fe9afcb6332d6f84bc820eb58e
b5aecc34319ccefb0bd3c63ee5e82d3d10c3bba8
refs/heads/main
2023-05-01T18:08:45.845414
2021-05-18T08:00:46
2021-05-18T08:00:46
367,491,755
0
0
null
null
null
null
UTF-8
C++
false
false
840
/*--------------------------------*- C++ -*----------------------------------*\ ========= | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 6.0 | | \\ / A nd | Website: https://openfoam.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; object decomposeParDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // numberOfSubdomains 256; method scotch; // ************************************************************************* //
[ "noreply@github.com" ]
noreply@github.com
55bcf9773cc196b3e9f8b64234a03c7fd6ba3246
5adbe94b29bfe5015ab9c5e38784ae12ef68e1b5
/algorithm/merge-sort/merge-sort-unittest.cc
a6eae7d188c7020758442ec189d968d0f6b8cb64
[]
no_license
kaivenhu/coding-problem
26c3c77799b286de6bd0c66be276aceec0e4586b
3966a320ae8a865646c4fd9f3dc6faae609e0ab7
refs/heads/master
2022-06-26T19:16:02.341237
2022-06-17T10:48:09
2022-06-17T10:49:08
225,041,119
0
0
null
null
null
null
UTF-8
C++
false
false
1,024
cc
#include <algorithm> #include <cstdlib> #include <ctime> #include <gtest/gtest.h> #include <coding/vec.h> #include "merge-sort.h" using namespace merge_sort; using namespace coding::vec; using std::vector; TEST(merge_sort, empty) { EXPECT_TRUE(IsVectorEqual({}, MergeSort::sort({}))); } TEST(merge_sort, one) { EXPECT_TRUE(IsVectorEqual({1}, MergeSort::sort({1}))); } TEST(merge_sort, basic) { EXPECT_TRUE(IsVectorEqual({1, 2, 3}, MergeSort::sort({2, 1, 3}))); } TEST(merge_sort, random) { srand(time(NULL)); for (int run = 0; run < 1000; ++run) { vector<int> vec; vector<int> ans; int num = rand() % 1000; for (int i = 0; i < num; ++i) { int x = (rand() % 1000) - 500; vec.push_back(x); } ans = vec; std::sort(ans.begin(), ans.end()); EXPECT_TRUE(IsVectorEqual(ans, MergeSort::sort(vec))); } } int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }
[ "kainbd0609@gmail.com" ]
kainbd0609@gmail.com
f8f2d2a93158c3ed42098d337c5a3b2fcf8494de
38c10c01007624cd2056884f25e0d6ab85442194
/chrome/browser/safe_browsing/threat_details.cc
50d956d93ebb5392b07ea616c6d2b29c56ae7b2d
[ "BSD-3-Clause" ]
permissive
zenoalbisser/chromium
6ecf37b6c030c84f1b26282bc4ef95769c62a9b2
e71f21b9b4b9b839f5093301974a45545dad2691
refs/heads/master
2022-12-25T14:23:18.568575
2016-07-14T21:49:52
2016-07-23T08:02:51
63,980,627
0
2
BSD-3-Clause
2022-12-12T12:43:41
2016-07-22T20:14:04
null
UTF-8
C++
false
false
11,911
cc
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // Implementation of the MalwareDetails class. #include "chrome/browser/safe_browsing/threat_details.h" #include "base/bind.h" #include "base/lazy_instance.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/safe_browsing/report.pb.h" #include "chrome/browser/safe_browsing/threat_details_cache.h" #include "chrome/browser/safe_browsing/threat_details_history.h" #include "chrome/common/safe_browsing/safebrowsing_messages.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" #include "net/url_request/url_request_context_getter.h" using content::BrowserThread; using content::NavigationEntry; using content::WebContents; using safe_browsing::ClientMalwareReportRequest; // Keep in sync with KMaxNodes in renderer/safe_browsing/malware_dom_details static const uint32 kMaxDomNodes = 500; // static ThreatDetailsFactory* ThreatDetails::factory_ = NULL; // The default ThreatDetailsFactory. Global, made a singleton so we // don't leak it. class ThreatDetailsFactoryImpl : public ThreatDetailsFactory { public: ThreatDetails* CreateThreatDetails( SafeBrowsingUIManager* ui_manager, WebContents* web_contents, const SafeBrowsingUIManager::UnsafeResource& unsafe_resource) override { return new ThreatDetails(ui_manager, web_contents, unsafe_resource); } private: friend struct base::DefaultLazyInstanceTraits<ThreatDetailsFactoryImpl>; ThreatDetailsFactoryImpl() {} DISALLOW_COPY_AND_ASSIGN(ThreatDetailsFactoryImpl); }; static base::LazyInstance<ThreatDetailsFactoryImpl> g_malware_details_factory_impl = LAZY_INSTANCE_INITIALIZER; // Create a ThreatDetails for the given tab. /* static */ ThreatDetails* ThreatDetails::NewThreatDetails( SafeBrowsingUIManager* ui_manager, WebContents* web_contents, const UnsafeResource& resource) { // Set up the factory if this has not been done already (tests do that // before this method is called). if (!factory_) factory_ = g_malware_details_factory_impl.Pointer(); return factory_->CreateThreatDetails(ui_manager, web_contents, resource); } // Create a ThreatDetails for the given tab. Runs in the UI thread. ThreatDetails::ThreatDetails(SafeBrowsingUIManager* ui_manager, content::WebContents* web_contents, const UnsafeResource& resource) : content::WebContentsObserver(web_contents), profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())), request_context_getter_(profile_->GetRequestContext()), ui_manager_(ui_manager), resource_(resource), cache_result_(false), cache_collector_(new ThreatDetailsCacheCollector), redirects_collector_(new ThreatDetailsRedirectsCollector(profile_)) { StartCollection(); } ThreatDetails::~ThreatDetails() {} bool ThreatDetails::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(ThreatDetails, message) IPC_MESSAGE_HANDLER(SafeBrowsingHostMsg_MalwareDOMDetails, OnReceivedThreatDOMDetails) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; } bool ThreatDetails::IsReportableUrl(const GURL& url) const { // TODO(panayiotis): also skip internal urls. return url.SchemeIs("http") || url.SchemeIs("https"); } // Looks for a Resource for the given url in resources_. If found, it // updates |resource|. Otherwise, it creates a new message, adds it to // resources_ and updates |resource| to point to it. // ClientMalwareReportRequest::Resource* ThreatDetails::FindOrCreateResource( const GURL& url) { safe_browsing::ResourceMap::iterator it = resources_.find(url.spec()); if (it != resources_.end()) return it->second.get(); // Create the resource for |url|. int id = resources_.size(); linked_ptr<ClientMalwareReportRequest::Resource> new_resource( new ClientMalwareReportRequest::Resource()); new_resource->set_url(url.spec()); new_resource->set_id(id); resources_[url.spec()] = new_resource; return new_resource.get(); } void ThreatDetails::AddUrl(const GURL& url, const GURL& parent, const std::string& tagname, const std::vector<GURL>* children) { if (!url.is_valid() || !IsReportableUrl(url)) return; // Find (or create) the resource for the url. ClientMalwareReportRequest::Resource* url_resource = FindOrCreateResource(url); if (!tagname.empty()) url_resource->set_tag_name(tagname); if (!parent.is_empty() && IsReportableUrl(parent)) { // Add the resource for the parent. ClientMalwareReportRequest::Resource* parent_resource = FindOrCreateResource(parent); // Update the parent-child relation url_resource->set_parent_id(parent_resource->id()); } if (children) { for (std::vector<GURL>::const_iterator it = children->begin(); it != children->end(); ++it) { ClientMalwareReportRequest::Resource* child_resource = FindOrCreateResource(*it); url_resource->add_child_ids(child_resource->id()); } } } void ThreatDetails::StartCollection() { DVLOG(1) << "Starting to compute malware details."; report_.reset(new ClientMalwareReportRequest()); if (IsReportableUrl(resource_.url)) report_->set_malware_url(resource_.url.spec()); GURL page_url = web_contents()->GetURL(); if (IsReportableUrl(page_url)) report_->set_page_url(page_url.spec()); GURL referrer_url; NavigationEntry* nav_entry = web_contents()->GetController().GetActiveEntry(); if (nav_entry) { referrer_url = nav_entry->GetReferrer().url; if (IsReportableUrl(referrer_url)) { report_->set_referrer_url(referrer_url.spec()); } } // Add the nodes, starting from the page url. AddUrl(page_url, GURL(), std::string(), NULL); // Add the resource_url and its original url, if non-empty and different. if (!resource_.original_url.is_empty() && resource_.url != resource_.original_url) { // Add original_url, as the parent of resource_url. AddUrl(resource_.original_url, GURL(), std::string(), NULL); AddUrl(resource_.url, resource_.original_url, std::string(), NULL); } else { AddUrl(resource_.url, GURL(), std::string(), NULL); } // Add the redirect urls, if non-empty. The redirect urls do not include the // original url, but include the unsafe url which is the last one of the // redirect urls chain GURL parent_url; // Set the original url as the parent of the first redirect url if it's not // empty. if (!resource_.original_url.is_empty()) parent_url = resource_.original_url; // Set the previous redirect url as the parent of the next one for (size_t i = 0; i < resource_.redirect_urls.size(); ++i) { AddUrl(resource_.redirect_urls[i], parent_url, std::string(), NULL); parent_url = resource_.redirect_urls[i]; } // Add the referrer url. if (nav_entry && !referrer_url.is_empty()) AddUrl(referrer_url, GURL(), std::string(), NULL); // Get URLs of frames, scripts etc from the DOM. // OnReceivedThreatDOMDetails will be called when the renderer replies. content::RenderViewHost* view = web_contents()->GetRenderViewHost(); view->Send(new SafeBrowsingMsg_GetMalwareDOMDetails(view->GetRoutingID())); } // When the renderer is done, this is called. void ThreatDetails::OnReceivedThreatDOMDetails( const std::vector<SafeBrowsingHostMsg_MalwareDOMDetails_Node>& params) { // Schedule this in IO thread, so it doesn't conflict with future users // of our data structures (eg GetSerializedReport). BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&ThreatDetails::AddDOMDetails, this, params)); } void ThreatDetails::AddDOMDetails( const std::vector<SafeBrowsingHostMsg_MalwareDOMDetails_Node>& params) { DCHECK_CURRENTLY_ON(BrowserThread::IO); DVLOG(1) << "Nodes from the DOM: " << params.size(); // If we have already started getting redirects from history service, // don't modify state, otherwise will invalidate the iterators. if (redirects_collector_->HasStarted()) return; // If we have already started collecting data from the HTTP cache, don't // modify our state. if (cache_collector_->HasStarted()) return; // Add the urls from the DOM to |resources_|. The renderer could be // sending bogus messages, so limit the number of nodes we accept. for (size_t i = 0; i < params.size() && i < kMaxDomNodes; ++i) { SafeBrowsingHostMsg_MalwareDOMDetails_Node node = params[i]; DVLOG(1) << node.url << ", " << node.tag_name << ", " << node.parent; AddUrl(node.url, node.parent, node.tag_name, &(node.children)); } } // Called from the SB Service on the IO thread, after the user has // closed the tab, or clicked proceed or goback. Since the user needs // to take an action, we expect this to be called after // OnReceivedThreatDOMDetails in most cases. If not, we don't include // the DOM data in our report. void ThreatDetails::FinishCollection(bool did_proceed, int num_visit) { DCHECK_CURRENTLY_ON(BrowserThread::IO); did_proceed_ = did_proceed; num_visits_ = num_visit; std::vector<GURL> urls; for (safe_browsing::ResourceMap::const_iterator it = resources_.begin(); it != resources_.end(); ++it) { urls.push_back(GURL(it->first)); } redirects_collector_->StartHistoryCollection( urls, base::Bind(&ThreatDetails::OnRedirectionCollectionReady, this)); } void ThreatDetails::OnRedirectionCollectionReady() { DCHECK_CURRENTLY_ON(BrowserThread::IO); const std::vector<safe_browsing::RedirectChain>& redirects = redirects_collector_->GetCollectedUrls(); for (size_t i = 0; i < redirects.size(); ++i) AddRedirectUrlList(redirects[i]); // Call the cache collector cache_collector_->StartCacheCollection( request_context_getter_.get(), &resources_, &cache_result_, base::Bind(&ThreatDetails::OnCacheCollectionReady, this)); } void ThreatDetails::AddRedirectUrlList(const std::vector<GURL>& urls) { DCHECK_CURRENTLY_ON(BrowserThread::IO); for (size_t i = 0; i < urls.size() - 1; ++i) { AddUrl(urls[i], urls[i + 1], std::string(), NULL); } } void ThreatDetails::OnCacheCollectionReady() { DVLOG(1) << "OnCacheCollectionReady."; // Add all the urls in our |resources_| maps to the |report_| protocol buffer. for (safe_browsing::ResourceMap::const_iterator it = resources_.begin(); it != resources_.end(); ++it) { ClientMalwareReportRequest::Resource* pb_resource = report_->add_resources(); pb_resource->CopyFrom(*(it->second)); const GURL url(pb_resource->url()); if (url.SchemeIs("https")) { // Don't report headers of HTTPS requests since they may contain private // cookies. We still retain the full URL. DVLOG(1) << "Clearing out HTTPS resource: " << pb_resource->url(); pb_resource->clear_request(); pb_resource->clear_response(); // Keep id, parent_id, child_ids, and tag_name. } } report_->set_did_proceed(did_proceed_); // Only sets repeat_visit if num_visits_ >= 0. if (num_visits_ >= 0) { report_->set_repeat_visit(num_visits_ > 0); } report_->set_complete(cache_result_); // Send the report, using the SafeBrowsingService. std::string serialized; if (!report_->SerializeToString(&serialized)) { DLOG(ERROR) << "Unable to serialize the malware report."; return; } ui_manager_->SendSerializedThreatDetails(serialized); }
[ "zeno.albisser@hemispherian.com" ]
zeno.albisser@hemispherian.com
d9e4ef8f54af7ce37b966bcbaec98752635de326
a993b98793857e93de978a6ef55103a37b414bbf
/content/browser/frame_host/navigator_impl_unittest.cc
a956d53b93c79f2d1719d87beadad6fc62eb422c
[ "BSD-3-Clause" ]
permissive
goby/chromium
339e6894f9fb38cc324baacec8d6f38fe016ec80
07aaa7750898bf9bdbff8163959d96a0bc1fe038
refs/heads/master
2023-01-10T18:22:31.622284
2017-01-09T11:22:55
2017-01-09T11:22:55
47,946,272
1
0
null
2017-01-09T11:22:56
2015-12-14T01:57:57
null
UTF-8
C++
false
false
53,530
cc
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include <stdint.h> #include "base/feature_list.h" #include "base/macros.h" #include "base/time/time.h" #include "build/build_config.h" #include "content/browser/frame_host/navigation_controller_impl.h" #include "content/browser/frame_host/navigation_entry_impl.h" #include "content/browser/frame_host/navigation_request.h" #include "content/browser/frame_host/navigation_request_info.h" #include "content/browser/frame_host/navigator.h" #include "content/browser/frame_host/navigator_impl.h" #include "content/browser/frame_host/render_frame_host_manager.h" #include "content/browser/site_instance_impl.h" #include "content/browser/streams/stream.h" #include "content/common/frame_messages.h" #include "content/common/navigation_params.h" #include "content/common/site_isolation_policy.h" #include "content/public/browser/navigation_data.h" #include "content/public/browser/stream_handle.h" #include "content/public/common/content_features.h" #include "content/public/common/url_constants.h" #include "content/public/common/url_utils.h" #include "content/public/test/browser_side_navigation_test_utils.h" #include "content/public/test/mock_render_process_host.h" #include "content/public/test/test_utils.h" #include "content/test/test_navigation_url_loader.h" #include "content/test/test_render_frame_host.h" #include "content/test/test_web_contents.h" #include "net/base/load_flags.h" #include "net/http/http_response_headers.h" #include "net/url_request/redirect_info.h" #include "ui/base/page_transition_types.h" #include "url/url_constants.h" #if !defined(OS_ANDROID) #include "content/browser/compositor/test/no_transport_image_transport_factory.h" #endif namespace content { class NavigatorTestWithBrowserSideNavigation : public RenderViewHostImplTestHarness { public: using SiteInstanceDescriptor = RenderFrameHostManager::SiteInstanceDescriptor; using SiteInstanceRelation = RenderFrameHostManager::SiteInstanceRelation; void SetUp() override { EnableBrowserSideNavigation(); RenderViewHostImplTestHarness::SetUp(); } void TearDown() override { RenderViewHostImplTestHarness::TearDown(); } TestNavigationURLLoader* GetLoaderForNavigationRequest( NavigationRequest* request) const { return static_cast<TestNavigationURLLoader*>(request->loader_for_testing()); } // Requests a navigation of the specified FrameTreeNode to the specified URL; // returns the unique ID of the pending NavigationEntry. int RequestNavigation(FrameTreeNode* node, const GURL& url) { return RequestNavigationWithParameters(node, url, Referrer(), ui::PAGE_TRANSITION_LINK); } // Requests a navigation of the specified FrameTreeNode to the specified URL, // using other specified parameters; returns the unique ID of the pending // NavigationEntry. int RequestNavigationWithParameters( FrameTreeNode* node, const GURL& url, const Referrer& referrer, ui::PageTransition transition_type) { NavigationController::LoadURLParams load_params(url); load_params.frame_tree_node_id = node->frame_tree_node_id(); load_params.referrer = referrer; load_params.transition_type = transition_type; controller().LoadURLWithParams(load_params); return controller().GetPendingEntry()->GetUniqueID(); } TestRenderFrameHost* GetSpeculativeRenderFrameHost(FrameTreeNode* node) { return static_cast<TestRenderFrameHost*>( node->render_manager()->speculative_render_frame_host_.get()); } // Checks if this RenderFrameHost sent a single FrameMsg_CommitNavigation // since the last clearing of the sink. // Note: caller must invoke ClearMessages on the sink at some point before // the tracked commit happens to clear up commit messages from previous // navigations. bool DidRenderFrameHostRequestCommit(TestRenderFrameHost* rfh) { const IPC::Message* message = rfh->GetProcess()->sink().GetUniqueMessageMatching( FrameMsg_CommitNavigation::ID); return message && rfh->GetRoutingID() == message->routing_id(); } scoped_refptr<SiteInstance> ConvertToSiteInstance( RenderFrameHostManager* rfhm, const SiteInstanceDescriptor& descriptor, SiteInstance* candidate_instance) { return rfhm->ConvertToSiteInstance(descriptor, candidate_instance); } }; // PlzNavigate: Test a complete browser-initiated navigation starting with a // non-live renderer. TEST_F(NavigatorTestWithBrowserSideNavigation, SimpleBrowserInitiatedNavigationFromNonLiveRenderer) { const GURL kUrl("http://chromium.org/"); EXPECT_FALSE(main_test_rfh()->IsRenderFrameLive()); // Start a browser-initiated navigation. int32_t site_instance_id = main_test_rfh()->GetSiteInstance()->GetId(); FrameTreeNode* node = main_test_rfh()->frame_tree_node(); int entry_id = RequestNavigation(node, kUrl); NavigationRequest* request = node->navigation_request(); ASSERT_TRUE(request); EXPECT_EQ(kUrl, request->common_params().url); EXPECT_TRUE(request->browser_initiated()); // As there's no live renderer the navigation should not wait for a // beforeUnload ACK from the renderer and start right away. EXPECT_EQ(NavigationRequest::STARTED, request->state()); ASSERT_TRUE(GetLoaderForNavigationRequest(request)); EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); EXPECT_FALSE(node->render_manager()->pending_frame_host()); // Have the current RenderFrameHost commit the navigation. scoped_refptr<ResourceResponse> response(new ResourceResponse); GetLoaderForNavigationRequest(request)->CallOnResponseStarted( response, MakeEmptyStream(), nullptr); EXPECT_TRUE(DidRenderFrameHostRequestCommit(main_test_rfh())); EXPECT_TRUE(main_test_rfh()->is_loading()); EXPECT_FALSE(node->navigation_request()); // Commit the navigation. main_test_rfh()->SendNavigate(entry_id, true, kUrl); EXPECT_TRUE(main_test_rfh()->is_active()); EXPECT_EQ(SiteInstanceImpl::GetSiteForURL(browser_context(), kUrl), main_test_rfh()->GetSiteInstance()->GetSiteURL()); EXPECT_EQ(kUrl, contents()->GetLastCommittedURL()); EXPECT_FALSE(node->render_manager()->pending_frame_host()); // The main RenderFrameHost should not have been changed, and the renderer // should have been initialized. EXPECT_EQ(site_instance_id, main_test_rfh()->GetSiteInstance()->GetId()); EXPECT_TRUE(main_test_rfh()->IsRenderFrameLive()); // After a navigation is finished no speculative RenderFrameHost should // exist. EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); // With PlzNavigate enabled a pending RenderFrameHost should never exist. EXPECT_FALSE(node->render_manager()->pending_frame_host()); } // PlzNavigate: Test a complete renderer-initiated same-site navigation. TEST_F(NavigatorTestWithBrowserSideNavigation, SimpleRendererInitiatedSameSiteNavigation) { const GURL kUrl1("http://www.chromium.org/"); const GURL kUrl2("http://www.chromium.org/Home"); contents()->NavigateAndCommit(kUrl1); EXPECT_TRUE(main_test_rfh()->IsRenderFrameLive()); // Start a renderer-initiated non-user-initiated navigation. process()->sink().ClearMessages(); main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl2, false); FrameTreeNode* node = main_test_rfh()->frame_tree_node(); NavigationRequest* request = node->navigation_request(); ASSERT_TRUE(request); // The navigation is immediately started as there's no need to wait for // beforeUnload to be executed. EXPECT_EQ(NavigationRequest::STARTED, request->state()); EXPECT_EQ(NavigationGestureAuto, request->common_params().gesture); EXPECT_EQ(kUrl2, request->common_params().url); EXPECT_FALSE(request->browser_initiated()); EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); // Have the current RenderFrameHost commit the navigation. scoped_refptr<ResourceResponse> response(new ResourceResponse); GetLoaderForNavigationRequest(request)->CallOnResponseStarted( response, MakeEmptyStream(), nullptr); EXPECT_TRUE(DidRenderFrameHostRequestCommit(main_test_rfh())); EXPECT_TRUE(main_test_rfh()->is_loading()); EXPECT_FALSE(node->navigation_request()); // Commit the navigation. main_test_rfh()->SendNavigate(0, true, kUrl2); EXPECT_TRUE(main_test_rfh()->is_active()); EXPECT_EQ(SiteInstanceImpl::GetSiteForURL(browser_context(), kUrl2), main_test_rfh()->GetSiteInstance()->GetSiteURL()); EXPECT_EQ(kUrl2, contents()->GetLastCommittedURL()); EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); EXPECT_FALSE(node->render_manager()->pending_frame_host()); } // PlzNavigate: Test a complete renderer-initiated navigation that should be // cross-site but does not result in a SiteInstance swap because its // renderer-initiated. TEST_F(NavigatorTestWithBrowserSideNavigation, SimpleRendererInitiatedCrossSiteNavigation) { const GURL kUrl1("http://www.chromium.org/"); const GURL kUrl2("http://www.google.com"); contents()->NavigateAndCommit(kUrl1); EXPECT_TRUE(main_test_rfh()->IsRenderFrameLive()); int32_t site_instance_id_1 = main_test_rfh()->GetSiteInstance()->GetId(); // Start a renderer-initiated non-user-initiated navigation. process()->sink().ClearMessages(); main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl2, false); FrameTreeNode* node = main_test_rfh()->frame_tree_node(); NavigationRequest* request = node->navigation_request(); ASSERT_TRUE(request); // The navigation is immediately started as there's no need to wait for // beforeUnload to be executed. EXPECT_EQ(NavigationRequest::STARTED, request->state()); EXPECT_EQ(NavigationGestureAuto, request->common_params().gesture); EXPECT_EQ(kUrl2, request->common_params().url); EXPECT_FALSE(request->browser_initiated()); if (SiteIsolationPolicy::AreCrossProcessFramesPossible()) { EXPECT_TRUE(GetSpeculativeRenderFrameHost(node)); } else { EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); } // Have the current RenderFrameHost commit the navigation. scoped_refptr<ResourceResponse> response(new ResourceResponse); GetLoaderForNavigationRequest(request)->CallOnResponseStarted( response, MakeEmptyStream(), nullptr); if (SiteIsolationPolicy::AreCrossProcessFramesPossible()) { EXPECT_TRUE( DidRenderFrameHostRequestCommit(GetSpeculativeRenderFrameHost(node))); } else { EXPECT_TRUE(DidRenderFrameHostRequestCommit(main_test_rfh())); } EXPECT_TRUE(main_test_rfh()->is_loading()); EXPECT_FALSE(node->navigation_request()); // Commit the navigation. main_test_rfh()->SendNavigate(0, true, kUrl2); EXPECT_TRUE(main_test_rfh()->is_active()); EXPECT_EQ(kUrl2, contents()->GetLastCommittedURL()); EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); EXPECT_FALSE(node->render_manager()->pending_frame_host()); // The SiteInstance did not change. EXPECT_EQ(site_instance_id_1, main_test_rfh()->GetSiteInstance()->GetId()); } // PlzNavigate: Test that a beforeUnload denial cancels the navigation. TEST_F(NavigatorTestWithBrowserSideNavigation, BeforeUnloadDenialCancelNavigation) { const GURL kUrl1("http://www.google.com/"); const GURL kUrl2("http://www.chromium.org/"); contents()->NavigateAndCommit(kUrl1); // Start a new navigation. FrameTreeNode* node = main_test_rfh()->frame_tree_node(); RequestNavigation(node, kUrl2); NavigationRequest* request = node->navigation_request(); ASSERT_TRUE(request); EXPECT_TRUE(request->browser_initiated()); EXPECT_EQ(NavigationRequest::WAITING_FOR_RENDERER_RESPONSE, request->state()); EXPECT_TRUE(GetSpeculativeRenderFrameHost(node)); RenderFrameDeletedObserver rfh_deleted_observer( GetSpeculativeRenderFrameHost(node)); // Simulate a beforeUnload denial. main_test_rfh()->SendBeforeUnloadACK(false); EXPECT_FALSE(node->navigation_request()); EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); EXPECT_TRUE(rfh_deleted_observer.deleted()); } // PlzNavigate: Test that a proper NavigationRequest is created by // RequestNavigation. TEST_F(NavigatorTestWithBrowserSideNavigation, BeginNavigation) { const GURL kUrl1("http://www.google.com/"); const GURL kUrl2("http://www.chromium.org/"); const GURL kUrl3("http://www.gmail.com/"); contents()->NavigateAndCommit(kUrl1); // Add a subframe. FrameTreeNode* root_node = contents()->GetFrameTree()->root(); TestRenderFrameHost* subframe_rfh = main_test_rfh()->AppendChild("Child"); ASSERT_TRUE(subframe_rfh); // Start a navigation at the subframe. FrameTreeNode* subframe_node = subframe_rfh->frame_tree_node(); RequestNavigation(subframe_node, kUrl2); NavigationRequest* subframe_request = subframe_node->navigation_request(); TestNavigationURLLoader* subframe_loader = GetLoaderForNavigationRequest(subframe_request); // Subframe navigations should start right away as they don't have to request // beforeUnload to run at the renderer. ASSERT_TRUE(subframe_request); ASSERT_TRUE(subframe_loader); EXPECT_EQ(NavigationRequest::STARTED, subframe_request->state()); EXPECT_EQ(kUrl2, subframe_request->common_params().url); EXPECT_EQ(kUrl2, subframe_loader->request_info()->common_params.url); // First party for cookies url should be that of the main frame. EXPECT_EQ(kUrl1, subframe_loader->request_info()->first_party_for_cookies); EXPECT_FALSE(subframe_loader->request_info()->is_main_frame); EXPECT_TRUE(subframe_loader->request_info()->parent_is_main_frame); EXPECT_TRUE(subframe_request->browser_initiated()); EXPECT_FALSE(GetSpeculativeRenderFrameHost(root_node)); // Subframe navigations should never create a speculative RenderFrameHost, // unless site-per-process is enabled. In that case, as the subframe // navigation is to a different site and is still ongoing, it should have one. if (AreAllSitesIsolatedForTesting()) { EXPECT_TRUE(GetSpeculativeRenderFrameHost(subframe_node)); } else { EXPECT_FALSE(GetSpeculativeRenderFrameHost(subframe_node)); } // Now start a navigation at the root node. RequestNavigation(root_node, kUrl3); NavigationRequest* main_request = root_node->navigation_request(); ASSERT_TRUE(main_request); EXPECT_EQ(NavigationRequest::WAITING_FOR_RENDERER_RESPONSE, main_request->state()); // Main frame navigation to a different site should use a speculative // RenderFrameHost. EXPECT_TRUE(GetSpeculativeRenderFrameHost(root_node)); // Simulate a BeforeUnloadACK IPC on the main frame. main_test_rfh()->SendBeforeUnloadACK(true); TestNavigationURLLoader* main_loader = GetLoaderForNavigationRequest(main_request); EXPECT_EQ(kUrl3, main_request->common_params().url); EXPECT_EQ(kUrl3, main_loader->request_info()->common_params.url); EXPECT_EQ(kUrl3, main_loader->request_info()->first_party_for_cookies); EXPECT_TRUE(main_loader->request_info()->is_main_frame); EXPECT_FALSE(main_loader->request_info()->parent_is_main_frame); EXPECT_TRUE(main_request->browser_initiated()); // BeforeUnloadACK was received from the renderer so the navigation should // have started. EXPECT_EQ(NavigationRequest::STARTED, main_request->state()); EXPECT_TRUE(GetSpeculativeRenderFrameHost(root_node)); // As the main frame hasn't yet committed the subframe still exists. Thus, the // above situation regarding subframe navigations is valid here. if (AreAllSitesIsolatedForTesting()) { EXPECT_TRUE(GetSpeculativeRenderFrameHost(subframe_node)); } else { EXPECT_FALSE(GetSpeculativeRenderFrameHost(subframe_node)); } } // PlzNavigate: Test that committing an HTTP 204 or HTTP 205 response cancels // the navigation. TEST_F(NavigatorTestWithBrowserSideNavigation, NoContent) { const GURL kUrl1("http://www.chromium.org/"); const GURL kUrl2("http://www.google.com/"); // Load a URL. contents()->NavigateAndCommit(kUrl1); FrameTreeNode* node = main_test_rfh()->frame_tree_node(); // Navigate to a different site. process()->sink().ClearMessages(); RequestNavigation(node, kUrl2); main_test_rfh()->SendBeforeUnloadACK(true); NavigationRequest* main_request = node->navigation_request(); ASSERT_TRUE(main_request); // Navigations to a different site do create a speculative RenderFrameHost. EXPECT_TRUE(GetSpeculativeRenderFrameHost(node)); // Commit an HTTP 204 response. scoped_refptr<ResourceResponse> response(new ResourceResponse); const char kNoContentHeaders[] = "HTTP/1.1 204 No Content\0\0"; response->head.headers = new net::HttpResponseHeaders( std::string(kNoContentHeaders, arraysize(kNoContentHeaders))); GetLoaderForNavigationRequest(main_request) ->CallOnResponseStarted(response, MakeEmptyStream(), nullptr); // There should be no pending nor speculative RenderFrameHost; the navigation // was aborted. EXPECT_FALSE(DidRenderFrameHostRequestCommit(main_test_rfh())); EXPECT_FALSE(node->navigation_request()); EXPECT_FALSE(node->render_manager()->pending_frame_host()); EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); // Now, repeat the test with 205 Reset Content. // Navigate to a different site again. process()->sink().ClearMessages(); RequestNavigation(node, kUrl2); main_test_rfh()->SendBeforeUnloadACK(true); main_request = node->navigation_request(); ASSERT_TRUE(main_request); EXPECT_TRUE(GetSpeculativeRenderFrameHost(node)); // Commit an HTTP 205 response. response = new ResourceResponse; const char kResetContentHeaders[] = "HTTP/1.1 205 Reset Content\0\0"; response->head.headers = new net::HttpResponseHeaders( std::string(kResetContentHeaders, arraysize(kResetContentHeaders))); GetLoaderForNavigationRequest(main_request) ->CallOnResponseStarted(response, MakeEmptyStream(), nullptr); // There should be no pending nor speculative RenderFrameHost; the navigation // was aborted. EXPECT_FALSE(DidRenderFrameHostRequestCommit(main_test_rfh())); EXPECT_FALSE(node->navigation_request()); EXPECT_FALSE(node->render_manager()->pending_frame_host()); EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); } // PlzNavigate: Test that a new RenderFrameHost is created when doing a cross // site navigation. TEST_F(NavigatorTestWithBrowserSideNavigation, CrossSiteNavigation) { const GURL kUrl1("http://www.chromium.org/"); const GURL kUrl2("http://www.google.com/"); contents()->NavigateAndCommit(kUrl1); RenderFrameHostImpl* initial_rfh = main_test_rfh(); FrameTreeNode* node = main_test_rfh()->frame_tree_node(); // Navigate to a different site. process()->sink().ClearMessages(); int entry_id = RequestNavigation(node, kUrl2); NavigationRequest* main_request = node->navigation_request(); ASSERT_TRUE(main_request); TestRenderFrameHost* speculative_rfh = GetSpeculativeRenderFrameHost(node); ASSERT_TRUE(speculative_rfh); // Receive the beforeUnload ACK. main_test_rfh()->SendBeforeUnloadACK(true); EXPECT_EQ(speculative_rfh, GetSpeculativeRenderFrameHost(node)); scoped_refptr<ResourceResponse> response(new ResourceResponse); GetLoaderForNavigationRequest(main_request) ->CallOnResponseStarted(response, MakeEmptyStream(), nullptr); EXPECT_EQ(speculative_rfh, GetSpeculativeRenderFrameHost(node)); EXPECT_TRUE(DidRenderFrameHostRequestCommit(speculative_rfh)); EXPECT_FALSE(DidRenderFrameHostRequestCommit(main_test_rfh())); speculative_rfh->SendNavigate(entry_id, true, kUrl2); RenderFrameHostImpl* final_rfh = main_test_rfh(); EXPECT_EQ(speculative_rfh, final_rfh); EXPECT_NE(initial_rfh, final_rfh); EXPECT_TRUE(final_rfh->IsRenderFrameLive()); EXPECT_TRUE(final_rfh->render_view_host()->IsRenderViewLive()); EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); } // PlzNavigate: Test that redirects are followed and the speculative // RenderFrameHost logic behaves as expected. TEST_F(NavigatorTestWithBrowserSideNavigation, RedirectCrossSite) { const GURL kUrl1("http://www.chromium.org/"); const GURL kUrl2("http://www.google.com/"); contents()->NavigateAndCommit(kUrl1); RenderFrameHostImpl* rfh = main_test_rfh(); FrameTreeNode* node = main_test_rfh()->frame_tree_node(); // Navigate to a URL on the same site. process()->sink().ClearMessages(); int entry_id = RequestNavigation(node, kUrl1); main_test_rfh()->SendBeforeUnloadACK(true); NavigationRequest* main_request = node->navigation_request(); ASSERT_TRUE(main_request); EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); // It then redirects to another site. GetLoaderForNavigationRequest(main_request)->SimulateServerRedirect(kUrl2); // The redirect should have been followed. EXPECT_EQ(1, GetLoaderForNavigationRequest(main_request)->redirect_count()); EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); // Have the RenderFrameHost commit the navigation. scoped_refptr<ResourceResponse> response(new ResourceResponse); GetLoaderForNavigationRequest(main_request) ->CallOnResponseStarted(response, MakeEmptyStream(), nullptr); TestRenderFrameHost* final_speculative_rfh = GetSpeculativeRenderFrameHost(node); EXPECT_TRUE(final_speculative_rfh); EXPECT_TRUE(DidRenderFrameHostRequestCommit(final_speculative_rfh)); // Commit the navigation. final_speculative_rfh->SendNavigate(entry_id, true, kUrl2); RenderFrameHostImpl* final_rfh = main_test_rfh(); ASSERT_TRUE(final_rfh); EXPECT_NE(rfh, final_rfh); EXPECT_EQ(final_speculative_rfh, final_rfh); EXPECT_TRUE(final_rfh->IsRenderFrameLive()); EXPECT_TRUE(final_rfh->render_view_host()->IsRenderViewLive()); EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); } // PlzNavigate: Test that a navigation is canceled if another browser-initiated // request has been issued in the meantime. Also confirms that the speculative // RenderFrameHost is correctly updated in the process. TEST_F(NavigatorTestWithBrowserSideNavigation, BrowserInitiatedNavigationCancel) { const GURL kUrl0("http://www.wikipedia.org/"); const GURL kUrl1("http://www.chromium.org/"); const GURL kUrl1_site = SiteInstance::GetSiteForURL(browser_context(), kUrl1); const GURL kUrl2("http://www.google.com/"); const GURL kUrl2_site = SiteInstance::GetSiteForURL(browser_context(), kUrl2); // Initialization. contents()->NavigateAndCommit(kUrl0); FrameTreeNode* node = main_test_rfh()->frame_tree_node(); // Request navigation to the 1st URL. process()->sink().ClearMessages(); RequestNavigation(node, kUrl1); main_test_rfh()->SendBeforeUnloadACK(true); NavigationRequest* request1 = node->navigation_request(); ASSERT_TRUE(request1); EXPECT_EQ(kUrl1, request1->common_params().url); EXPECT_TRUE(request1->browser_initiated()); base::WeakPtr<TestNavigationURLLoader> loader1 = GetLoaderForNavigationRequest(request1)->AsWeakPtr(); EXPECT_TRUE(loader1); // Confirm a speculative RenderFrameHost was created. TestRenderFrameHost* speculative_rfh = GetSpeculativeRenderFrameHost(node); ASSERT_TRUE(speculative_rfh); int32_t site_instance_id_1 = speculative_rfh->GetSiteInstance()->GetId(); EXPECT_EQ(kUrl1_site, speculative_rfh->GetSiteInstance()->GetSiteURL()); // Request navigation to the 2nd URL; the NavigationRequest must have been // replaced by a new one with a different URL. int entry_id = RequestNavigation(node, kUrl2); main_test_rfh()->SendBeforeUnloadACK(true); NavigationRequest* request2 = node->navigation_request(); ASSERT_TRUE(request2); EXPECT_EQ(kUrl2, request2->common_params().url); EXPECT_TRUE(request2->browser_initiated()); // Confirm that the first loader got destroyed. EXPECT_FALSE(loader1); // Confirm that a new speculative RenderFrameHost was created. speculative_rfh = GetSpeculativeRenderFrameHost(node); ASSERT_TRUE(speculative_rfh); int32_t site_instance_id_2 = speculative_rfh->GetSiteInstance()->GetId(); EXPECT_NE(site_instance_id_1, site_instance_id_2); // Have the RenderFrameHost commit the navigation. scoped_refptr<ResourceResponse> response(new ResourceResponse); GetLoaderForNavigationRequest(request2)->CallOnResponseStarted( response, MakeEmptyStream(), nullptr); EXPECT_TRUE(DidRenderFrameHostRequestCommit(speculative_rfh)); EXPECT_FALSE(DidRenderFrameHostRequestCommit(main_test_rfh())); // Commit the navigation. speculative_rfh->SendNavigate(entry_id, true, kUrl2); // Confirm that the commit corresponds to the new request. ASSERT_TRUE(main_test_rfh()); EXPECT_EQ(kUrl2_site, main_test_rfh()->GetSiteInstance()->GetSiteURL()); EXPECT_EQ(kUrl2, contents()->GetLastCommittedURL()); // Confirm that the committed RenderFrameHost is the latest speculative one. EXPECT_EQ(site_instance_id_2, main_test_rfh()->GetSiteInstance()->GetId()); } // PlzNavigate: Test that a browser-initiated navigation is canceled if a // renderer-initiated user-initiated request has been issued in the meantime. TEST_F(NavigatorTestWithBrowserSideNavigation, RendererUserInitiatedNavigationCancel) { const GURL kUrl0("http://www.wikipedia.org/"); const GURL kUrl1("http://www.chromium.org/"); const GURL kUrl2("http://www.google.com/"); // Initialization. contents()->NavigateAndCommit(kUrl0); FrameTreeNode* node = main_test_rfh()->frame_tree_node(); // Start a browser-initiated navigation to the 1st URL and receive its // beforeUnload ACK. process()->sink().ClearMessages(); RequestNavigation(node, kUrl1); main_test_rfh()->SendBeforeUnloadACK(true); NavigationRequest* request1 = node->navigation_request(); ASSERT_TRUE(request1); EXPECT_EQ(kUrl1, request1->common_params().url); EXPECT_TRUE(request1->browser_initiated()); base::WeakPtr<TestNavigationURLLoader> loader1 = GetLoaderForNavigationRequest(request1)->AsWeakPtr(); EXPECT_TRUE(loader1); // Confirm that a speculative RenderFrameHost was created. ASSERT_TRUE(GetSpeculativeRenderFrameHost(node)); // Now receive a renderer-initiated user-initiated request. It should replace // the current NavigationRequest. main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl2, true); NavigationRequest* request2 = node->navigation_request(); ASSERT_TRUE(request2); EXPECT_EQ(kUrl2, request2->common_params().url); EXPECT_FALSE(request2->browser_initiated()); EXPECT_EQ(NavigationGestureUser, request2->common_params().gesture); // Confirm that the first loader got destroyed. EXPECT_FALSE(loader1); // Confirm that the speculative RenderFrameHost was destroyed in the non // SitePerProcess case. if (SiteIsolationPolicy::AreCrossProcessFramesPossible()) { EXPECT_TRUE(GetSpeculativeRenderFrameHost(node)); } else { EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); } // Have the RenderFrameHost commit the navigation. scoped_refptr<ResourceResponse> response(new ResourceResponse); GetLoaderForNavigationRequest(request2)->CallOnResponseStarted( response, MakeEmptyStream(), nullptr); if (SiteIsolationPolicy::AreCrossProcessFramesPossible()) { EXPECT_TRUE( DidRenderFrameHostRequestCommit(GetSpeculativeRenderFrameHost(node))); } else { EXPECT_TRUE(DidRenderFrameHostRequestCommit(main_test_rfh())); } // Commit the navigation. main_test_rfh()->SendNavigate(0, true, kUrl2); // Confirm that the commit corresponds to the new request. ASSERT_TRUE(main_test_rfh()); EXPECT_EQ(kUrl2, contents()->GetLastCommittedURL()); } // PlzNavigate: Test that a renderer-initiated user-initiated navigation is NOT // canceled if a renderer-initiated non-user-initiated request is issued in the // meantime. TEST_F(NavigatorTestWithBrowserSideNavigation, RendererNonUserInitiatedNavigationDoesntCancelRendererUserInitiated) { const GURL kUrl0("http://www.wikipedia.org/"); const GURL kUrl1("http://www.chromium.org/"); const GURL kUrl2("http://www.google.com/"); // Initialization. contents()->NavigateAndCommit(kUrl0); FrameTreeNode* node = main_test_rfh()->frame_tree_node(); // Start a renderer-initiated user-initiated navigation to the 1st URL. process()->sink().ClearMessages(); main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl1, true); NavigationRequest* request1 = node->navigation_request(); ASSERT_TRUE(request1); EXPECT_EQ(kUrl1, request1->common_params().url); EXPECT_FALSE(request1->browser_initiated()); EXPECT_EQ(NavigationGestureUser, request1->common_params().gesture); if (SiteIsolationPolicy::AreCrossProcessFramesPossible()) { EXPECT_TRUE(GetSpeculativeRenderFrameHost(node)); } else { EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); } // Now receive a renderer-initiated non-user-initiated request. Nothing should // change. main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl2, false); NavigationRequest* request2 = node->navigation_request(); ASSERT_TRUE(request2); EXPECT_EQ(request1, request2); EXPECT_EQ(kUrl1, request2->common_params().url); EXPECT_FALSE(request2->browser_initiated()); EXPECT_EQ(NavigationGestureUser, request2->common_params().gesture); if (SiteIsolationPolicy::AreCrossProcessFramesPossible()) { EXPECT_TRUE(GetSpeculativeRenderFrameHost(node)); } else { EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); } // Have the RenderFrameHost commit the navigation. scoped_refptr<ResourceResponse> response(new ResourceResponse); GetLoaderForNavigationRequest(request2)->CallOnResponseStarted( response, MakeEmptyStream(), nullptr); if (SiteIsolationPolicy::AreCrossProcessFramesPossible()) { EXPECT_TRUE( DidRenderFrameHostRequestCommit(GetSpeculativeRenderFrameHost(node))); } else { EXPECT_TRUE(DidRenderFrameHostRequestCommit(main_test_rfh())); } // Commit the navigation. main_test_rfh()->SendNavigate(0, true, kUrl1); EXPECT_EQ(kUrl1, contents()->GetLastCommittedURL()); } // PlzNavigate: Test that a browser-initiated navigation is NOT canceled if a // renderer-initiated non-user-initiated request is issued in the meantime. TEST_F(NavigatorTestWithBrowserSideNavigation, RendererNonUserInitiatedNavigationDoesntCancelBrowserInitiated) { const GURL kUrl0("http://www.wikipedia.org/"); const GURL kUrl1("http://www.chromium.org/"); const GURL kUrl2("http://www.google.com/"); // Initialization. contents()->NavigateAndCommit(kUrl0); FrameTreeNode* node = main_test_rfh()->frame_tree_node(); // Start a browser-initiated navigation to the 1st URL. process()->sink().ClearMessages(); int entry_id = RequestNavigation(node, kUrl1); NavigationRequest* request1 = node->navigation_request(); ASSERT_TRUE(request1); EXPECT_EQ(kUrl1, request1->common_params().url); EXPECT_TRUE(request1->browser_initiated()); EXPECT_TRUE(GetSpeculativeRenderFrameHost(node)); // Now receive a renderer-initiated non-user-initiated request. Nothing should // change. main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl2, false); NavigationRequest* request2 = node->navigation_request(); ASSERT_TRUE(request2); EXPECT_EQ(request1, request2); EXPECT_EQ(kUrl1, request2->common_params().url); EXPECT_TRUE(request2->browser_initiated()); EXPECT_TRUE(GetSpeculativeRenderFrameHost(node)); // Now receive the beforeUnload ACK from the still ongoing navigation. main_test_rfh()->SendBeforeUnloadACK(true); TestRenderFrameHost* speculative_rfh = GetSpeculativeRenderFrameHost(node); ASSERT_TRUE(speculative_rfh); // Have the RenderFrameHost commit the navigation. scoped_refptr<ResourceResponse> response(new ResourceResponse); GetLoaderForNavigationRequest(request2)->CallOnResponseStarted( response, MakeEmptyStream(), nullptr); EXPECT_TRUE(DidRenderFrameHostRequestCommit(speculative_rfh)); EXPECT_FALSE(DidRenderFrameHostRequestCommit(main_test_rfh())); // Commit the navigation. speculative_rfh->SendNavigate(entry_id, true, kUrl1); EXPECT_EQ(kUrl1, contents()->GetLastCommittedURL()); } // PlzNavigate: Test that a renderer-initiated non-user-initiated navigation is // canceled if a another similar request is issued in the meantime. TEST_F(NavigatorTestWithBrowserSideNavigation, RendererNonUserInitiatedNavigationCancelSimilarNavigation) { const GURL kUrl0("http://www.wikipedia.org/"); const GURL kUrl1("http://www.chromium.org/"); const GURL kUrl2("http://www.google.com/"); // Initialization. contents()->NavigateAndCommit(kUrl0); FrameTreeNode* node = main_test_rfh()->frame_tree_node(); int32_t site_instance_id_0 = main_test_rfh()->GetSiteInstance()->GetId(); // Start a renderer-initiated non-user-initiated navigation to the 1st URL. process()->sink().ClearMessages(); main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl1, false); NavigationRequest* request1 = node->navigation_request(); ASSERT_TRUE(request1); EXPECT_EQ(kUrl1, request1->common_params().url); EXPECT_FALSE(request1->browser_initiated()); EXPECT_EQ(NavigationGestureAuto, request1->common_params().gesture); if (SiteIsolationPolicy::AreCrossProcessFramesPossible()) { EXPECT_TRUE(GetSpeculativeRenderFrameHost(node)); } else { EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); } base::WeakPtr<TestNavigationURLLoader> loader1 = GetLoaderForNavigationRequest(request1)->AsWeakPtr(); EXPECT_TRUE(loader1); // Now receive a 2nd similar request that should replace the current one. main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl2, false); NavigationRequest* request2 = node->navigation_request(); EXPECT_EQ(kUrl2, request2->common_params().url); EXPECT_FALSE(request2->browser_initiated()); EXPECT_EQ(NavigationGestureAuto, request2->common_params().gesture); if (SiteIsolationPolicy::AreCrossProcessFramesPossible()) { EXPECT_TRUE(GetSpeculativeRenderFrameHost(node)); } else { EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); } // Confirm that the first loader got destroyed. EXPECT_FALSE(loader1); // Have the RenderFrameHost commit the navigation. scoped_refptr<ResourceResponse> response(new ResourceResponse); GetLoaderForNavigationRequest(request2)->CallOnResponseStarted( response, MakeEmptyStream(), nullptr); if (SiteIsolationPolicy::AreCrossProcessFramesPossible()) { EXPECT_TRUE( DidRenderFrameHostRequestCommit(GetSpeculativeRenderFrameHost(node))); } else { EXPECT_TRUE(DidRenderFrameHostRequestCommit(main_test_rfh())); } // Commit the navigation. main_test_rfh()->SendNavigate(0, true, kUrl2); EXPECT_EQ(kUrl2, contents()->GetLastCommittedURL()); // The SiteInstance did not change. EXPECT_EQ(site_instance_id_0, main_test_rfh()->GetSiteInstance()->GetId()); } // PlzNavigate: Test that a reload navigation is properly signaled to the // RenderFrame when the navigation can commit. A speculative RenderFrameHost // should not be created at any step. TEST_F(NavigatorTestWithBrowserSideNavigation, Reload) { const GURL kUrl("http://www.google.com/"); contents()->NavigateAndCommit(kUrl); FrameTreeNode* node = main_test_rfh()->frame_tree_node(); controller().Reload(false); int entry_id = controller().GetPendingEntry()->GetUniqueID(); // A NavigationRequest should have been generated. NavigationRequest* main_request = node->navigation_request(); ASSERT_TRUE(main_request != NULL); EXPECT_EQ(FrameMsg_Navigate_Type::RELOAD_MAIN_RESOURCE, main_request->common_params().navigation_type); main_test_rfh()->PrepareForCommit(); EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); main_test_rfh()->SendNavigate(entry_id, false, kUrl); EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); // Now do a shift+reload. controller().ReloadBypassingCache(false); // A NavigationRequest should have been generated. main_request = node->navigation_request(); ASSERT_TRUE(main_request != NULL); EXPECT_EQ(FrameMsg_Navigate_Type::RELOAD_BYPASSING_CACHE, main_request->common_params().navigation_type); main_test_rfh()->PrepareForCommit(); EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); } // PlzNavigate: Confirm that a speculative RenderFrameHost is used when // navigating from one site to another. TEST_F(NavigatorTestWithBrowserSideNavigation, SpeculativeRendererWorksBaseCase) { // Navigate to an initial site. const GURL kUrlInit("http://wikipedia.org/"); contents()->NavigateAndCommit(kUrlInit); FrameTreeNode* node = main_test_rfh()->frame_tree_node(); // Begin navigating to another site. const GURL kUrl("http://google.com/"); process()->sink().ClearMessages(); int entry_id = RequestNavigation(node, kUrl); TestRenderFrameHost* speculative_rfh = GetSpeculativeRenderFrameHost(node); ASSERT_TRUE(speculative_rfh); EXPECT_NE(speculative_rfh, main_test_rfh()); // Receive the beforeUnload ACK. main_test_rfh()->SendBeforeUnloadACK(true); EXPECT_EQ(speculative_rfh, GetSpeculativeRenderFrameHost(node)); EXPECT_EQ(SiteInstanceImpl::GetSiteForURL(browser_context(), kUrl), speculative_rfh->GetSiteInstance()->GetSiteURL()); EXPECT_FALSE(node->render_manager()->pending_frame_host()); int32_t site_instance_id = speculative_rfh->GetSiteInstance()->GetId(); // Ask Navigator to commit the navigation by simulating a call to // OnResponseStarted. scoped_refptr<ResourceResponse> response(new ResourceResponse); GetLoaderForNavigationRequest(node->navigation_request()) ->CallOnResponseStarted(response, MakeEmptyStream(), nullptr); EXPECT_EQ(speculative_rfh, GetSpeculativeRenderFrameHost(node)); EXPECT_TRUE(DidRenderFrameHostRequestCommit(speculative_rfh)); EXPECT_EQ(site_instance_id, speculative_rfh->GetSiteInstance()->GetId()); EXPECT_FALSE(node->render_manager()->pending_frame_host()); // Invoke OnDidCommitProvisionalLoad. speculative_rfh->SendNavigate(entry_id, true, kUrl); EXPECT_EQ(site_instance_id, main_test_rfh()->GetSiteInstance()->GetId()); EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); EXPECT_FALSE(node->render_manager()->pending_frame_host()); } // PlzNavigate: Confirm that a speculative RenderFrameHost is thrown away when // the final URL's site differs from the initial one due to redirects. TEST_F(NavigatorTestWithBrowserSideNavigation, SpeculativeRendererDiscardedAfterRedirectToAnotherSite) { // Navigate to an initial site. const GURL kUrlInit("http://wikipedia.org/"); contents()->NavigateAndCommit(kUrlInit); FrameTreeNode* node = main_test_rfh()->frame_tree_node(); int32_t init_site_instance_id = main_test_rfh()->GetSiteInstance()->GetId(); // Begin navigating to another site. const GURL kUrl("http://google.com/"); process()->sink().ClearMessages(); int entry_id = RequestNavigation(node, kUrl); TestRenderFrameHost* speculative_rfh = GetSpeculativeRenderFrameHost(node); ASSERT_TRUE(speculative_rfh); int32_t site_instance_id = speculative_rfh->GetSiteInstance()->GetId(); RenderFrameDeletedObserver rfh_deleted_observer(speculative_rfh); EXPECT_NE(init_site_instance_id, site_instance_id); EXPECT_EQ(init_site_instance_id, main_test_rfh()->GetSiteInstance()->GetId()); EXPECT_NE(speculative_rfh, main_test_rfh()); EXPECT_EQ(SiteInstanceImpl::GetSiteForURL(browser_context(), kUrl), speculative_rfh->GetSiteInstance()->GetSiteURL()); // Receive the beforeUnload ACK. main_test_rfh()->SendBeforeUnloadACK(true); EXPECT_EQ(speculative_rfh, GetSpeculativeRenderFrameHost(node)); // It then redirects to yet another site. NavigationRequest* main_request = node->navigation_request(); ASSERT_TRUE(main_request); const GURL kUrlRedirect("https://www.google.com/"); GetLoaderForNavigationRequest(main_request) ->SimulateServerRedirect(kUrlRedirect); EXPECT_EQ(init_site_instance_id, main_test_rfh()->GetSiteInstance()->GetId()); // For now, ensure that the speculative RenderFrameHost does not change after // the redirect. // TODO(carlosk): once the speculative RenderFrameHost updates with redirects // this next check will be changed to verify that it actually happens. EXPECT_EQ(speculative_rfh, GetSpeculativeRenderFrameHost(node)); EXPECT_EQ(site_instance_id, speculative_rfh->GetSiteInstance()->GetId()); EXPECT_FALSE(rfh_deleted_observer.deleted()); // Commit the navigation with Navigator by simulating the call to // OnResponseStarted. scoped_refptr<ResourceResponse> response(new ResourceResponse); GetLoaderForNavigationRequest(main_request) ->CallOnResponseStarted(response, MakeEmptyStream(), nullptr); speculative_rfh = GetSpeculativeRenderFrameHost(node); ASSERT_TRUE(speculative_rfh); EXPECT_TRUE(DidRenderFrameHostRequestCommit(speculative_rfh)); EXPECT_EQ(init_site_instance_id, main_test_rfh()->GetSiteInstance()->GetId()); EXPECT_TRUE(rfh_deleted_observer.deleted()); // Once commit happens the speculative RenderFrameHost is updated to match the // known final SiteInstance. EXPECT_EQ(SiteInstanceImpl::GetSiteForURL(browser_context(), kUrlRedirect), speculative_rfh->GetSiteInstance()->GetSiteURL()); int32_t redirect_site_instance_id = speculative_rfh->GetSiteInstance()->GetId(); EXPECT_NE(init_site_instance_id, redirect_site_instance_id); EXPECT_NE(site_instance_id, redirect_site_instance_id); // Invoke OnDidCommitProvisionalLoad. speculative_rfh->SendNavigate(entry_id, true, kUrlRedirect); // Check that the speculative RenderFrameHost was swapped in. EXPECT_EQ(redirect_site_instance_id, main_test_rfh()->GetSiteInstance()->GetId()); EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); } // PlzNavigate: Verify that data urls are properly handled. TEST_F(NavigatorTestWithBrowserSideNavigation, DataUrls) { const GURL kUrl1("http://wikipedia.org/"); const GURL kUrl2("data:text/html,test"); // Navigate to an initial site. contents()->NavigateAndCommit(kUrl1); FrameTreeNode* node = main_test_rfh()->frame_tree_node(); // Navigate to a data url. The request should have been sent to the IO // thread and not committed immediately. int entry_id = RequestNavigation(node, kUrl2); TestRenderFrameHost* speculative_rfh = GetSpeculativeRenderFrameHost(node); ASSERT_TRUE(speculative_rfh); EXPECT_FALSE(speculative_rfh->is_loading()); EXPECT_TRUE(node->navigation_request()); speculative_rfh->PrepareForCommit(); EXPECT_TRUE(speculative_rfh->is_loading()); EXPECT_FALSE(node->navigation_request()); EXPECT_NE(main_test_rfh(), speculative_rfh); speculative_rfh->SendNavigate(entry_id, true, kUrl2); EXPECT_EQ(main_test_rfh(), speculative_rfh); // Go back to the initial site. contents()->NavigateAndCommit(kUrl1); // Do a renderer-initiated navigation to a data url. The request should be // sent to the IO thread. TestRenderFrameHost* main_rfh = main_test_rfh(); main_rfh->SendRendererInitiatedNavigationRequest(kUrl2, true); EXPECT_TRUE(main_rfh->is_loading()); EXPECT_TRUE(node->navigation_request()); EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); } // Tests several cases for converting SiteInstanceDescriptors into // SiteInstances: // 1) Pointer to the current SiteInstance. // 2) Pointer to an unrelated SiteInstance. // 3) Same-site URL, related. // 4) Cross-site URL, related. // 5) Same-site URL, unrelated (with and without candidate SiteInstances). // 6) Cross-site URL, unrelated (with candidate SiteInstance). TEST_F(NavigatorTestWithBrowserSideNavigation, SiteInstanceDescriptionConversion) { // Navigate to set a current SiteInstance on the RenderFrameHost. GURL kUrl1("http://a.com"); contents()->NavigateAndCommit(kUrl1); SiteInstance* current_instance = main_test_rfh()->GetSiteInstance(); ASSERT_TRUE(current_instance); // 1) Convert a descriptor pointing to the current instance. RenderFrameHostManager* rfhm = main_test_rfh()->frame_tree_node()->render_manager(); { SiteInstanceDescriptor descriptor(current_instance); scoped_refptr<SiteInstance> converted_instance = ConvertToSiteInstance(rfhm, descriptor, nullptr); EXPECT_EQ(current_instance, converted_instance); } // 2) Convert a descriptor pointing an instance unrelated to the current one, // with a different site. GURL kUrl2("http://b.com"); scoped_refptr<SiteInstance> unrelated_instance( SiteInstance::CreateForURL(browser_context(), kUrl2)); EXPECT_FALSE( current_instance->IsRelatedSiteInstance(unrelated_instance.get())); { SiteInstanceDescriptor descriptor(unrelated_instance.get()); scoped_refptr<SiteInstance> converted_instance = ConvertToSiteInstance(rfhm, descriptor, nullptr); EXPECT_EQ(unrelated_instance.get(), converted_instance); } // 3) Convert a descriptor of a related instance with the same site as the // current one. GURL kUrlSameSiteAs1("http://www.a.com/foo"); { SiteInstanceDescriptor descriptor(browser_context(), kUrlSameSiteAs1, SiteInstanceRelation::RELATED); scoped_refptr<SiteInstance> converted_instance = ConvertToSiteInstance(rfhm, descriptor, nullptr); EXPECT_EQ(current_instance, converted_instance); } // 4) Convert a descriptor of a related instance with a site different from // the current one. GURL kUrlSameSiteAs2("http://www.b.com/foo"); scoped_refptr<SiteInstance> related_instance; { SiteInstanceDescriptor descriptor(browser_context(), kUrlSameSiteAs2, SiteInstanceRelation::RELATED); related_instance = ConvertToSiteInstance(rfhm, descriptor, nullptr); // Should return a new instance, related to the current, set to the new site // URL. EXPECT_TRUE( current_instance->IsRelatedSiteInstance(related_instance.get())); EXPECT_NE(current_instance, related_instance.get()); EXPECT_NE(unrelated_instance.get(), related_instance.get()); EXPECT_EQ(SiteInstance::GetSiteForURL(browser_context(), kUrlSameSiteAs2), related_instance->GetSiteURL()); } // 5) Convert a descriptor of an unrelated instance with the same site as the // current one, several times, with and without candidate sites. { SiteInstanceDescriptor descriptor(browser_context(), kUrlSameSiteAs1, SiteInstanceRelation::UNRELATED); scoped_refptr<SiteInstance> converted_instance_1 = ConvertToSiteInstance(rfhm, descriptor, nullptr); // Should return a new instance, unrelated to the current one, set to the // provided site URL. EXPECT_FALSE( current_instance->IsRelatedSiteInstance(converted_instance_1.get())); EXPECT_NE(current_instance, converted_instance_1.get()); EXPECT_NE(unrelated_instance.get(), converted_instance_1.get()); EXPECT_EQ(SiteInstance::GetSiteForURL(browser_context(), kUrlSameSiteAs1), converted_instance_1->GetSiteURL()); // Does the same but this time using unrelated_instance as a candidate, // which has a different site. scoped_refptr<SiteInstance> converted_instance_2 = ConvertToSiteInstance(rfhm, descriptor, unrelated_instance.get()); // Should return yet another new instance, unrelated to the current one, set // to the same site URL. EXPECT_FALSE( current_instance->IsRelatedSiteInstance(converted_instance_2.get())); EXPECT_NE(current_instance, converted_instance_2.get()); EXPECT_NE(unrelated_instance.get(), converted_instance_2.get()); EXPECT_NE(converted_instance_1.get(), converted_instance_2.get()); EXPECT_EQ(SiteInstance::GetSiteForURL(browser_context(), kUrlSameSiteAs1), converted_instance_2->GetSiteURL()); // Converts once more but with |converted_instance_1| as a candidate. scoped_refptr<SiteInstance> converted_instance_3 = ConvertToSiteInstance(rfhm, descriptor, converted_instance_1.get()); // Should return |converted_instance_1| because its site matches and it is // unrelated to the current SiteInstance. EXPECT_EQ(converted_instance_1.get(), converted_instance_3); } // 6) Convert a descriptor of an unrelated instance with the same site of // related_instance and using it as a candidate. { SiteInstanceDescriptor descriptor(browser_context(), kUrlSameSiteAs2, SiteInstanceRelation::UNRELATED); scoped_refptr<SiteInstance> converted_instance_1 = ConvertToSiteInstance(rfhm, descriptor, related_instance.get()); // Should return a new instance, unrelated to the current, set to the // provided site URL. EXPECT_FALSE( current_instance->IsRelatedSiteInstance(converted_instance_1.get())); EXPECT_NE(related_instance.get(), converted_instance_1.get()); EXPECT_NE(unrelated_instance.get(), converted_instance_1.get()); EXPECT_EQ(SiteInstance::GetSiteForURL(browser_context(), kUrlSameSiteAs2), converted_instance_1->GetSiteURL()); scoped_refptr<SiteInstance> converted_instance_2 = ConvertToSiteInstance(rfhm, descriptor, unrelated_instance.get()); // Should return |unrelated_instance| because its site matches and it is // unrelated to the current SiteInstance. EXPECT_EQ(unrelated_instance.get(), converted_instance_2); } } namespace { void SetWithinPage(const GURL& url, FrameHostMsg_DidCommitProvisionalLoad_Params* params) { params->was_within_same_page = true; params->url = url; params->origin = url::Origin(url); } } // A renderer process might try and claim that a cross site navigation was // within the same page by setting was_within_same_page = true for // FrameHostMsg_DidCommitProvisionalLoad. Such case should be detected on the // browser side and the renderer process should be killed. TEST_F(NavigatorTestWithBrowserSideNavigation, CrossSiteClaimWithinPage) { const GURL kUrl1("http://www.chromium.org/"); const GURL kUrl2("http://www.google.com/"); contents()->NavigateAndCommit(kUrl1); FrameTreeNode* node = main_test_rfh()->frame_tree_node(); // Navigate to a different site. int entry_id = RequestNavigation(node, kUrl2); main_test_rfh()->PrepareForCommit(); // Claim that the navigation was within same page. int bad_msg_count = process()->bad_msg_count(); GetSpeculativeRenderFrameHost(node)->SendNavigateWithModificationCallback( entry_id, true, kUrl2, base::Bind(SetWithinPage, kUrl1)); EXPECT_EQ(process()->bad_msg_count(), bad_msg_count + 1); } // Tests that an ongoing NavigationRequest is deleted when a same-site // user-initiated navigation commits. TEST_F(NavigatorTestWithBrowserSideNavigation, NavigationRequestDeletedWhenUserInitiatedCommits) { const GURL kUrl1("http://www.chromium.org/"); const GURL kUrl2("http://www.chromium.org/foo"); const GURL kUrl3("http://www.google.com/"); contents()->NavigateAndCommit(kUrl1); FrameTreeNode* node = main_test_rfh()->frame_tree_node(); // Navigate same-site. int entry_id = RequestNavigation(node, kUrl2); main_test_rfh()->PrepareForCommit(); EXPECT_TRUE(main_test_rfh()->is_loading()); EXPECT_FALSE(node->navigation_request()); // Start a new cross-site navigation. The current RFH should still be trying // to commit the previous navigation, but we create a NavigationRequest in the // FrameTreeNode. RequestNavigation(node, kUrl3); EXPECT_TRUE(main_test_rfh()->is_loading()); EXPECT_TRUE(node->navigation_request()); EXPECT_TRUE(GetSpeculativeRenderFrameHost(node)); // The first navigation commits. This should clear up the speculative RFH and // the ongoing NavigationRequest. main_test_rfh()->SendNavigate(entry_id, true, kUrl2); EXPECT_FALSE(node->navigation_request()); EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); } // Tests that an ongoing NavigationRequest is deleted when a cross-site // navigation commits. TEST_F(NavigatorTestWithBrowserSideNavigation, NavigationRequestDeletedWhenCrossSiteCommits) { const GURL kUrl1("http://www.chromium.org/"); const GURL kUrl2("http://www.google.com/"); const GURL kUrl3("http://www.google.com/foo"); contents()->NavigateAndCommit(kUrl1); FrameTreeNode* node = main_test_rfh()->frame_tree_node(); // Navigate cross-site. int entry_id = RequestNavigation(node, kUrl2); main_test_rfh()->PrepareForCommit(); TestRenderFrameHost* speculative_rfh = GetSpeculativeRenderFrameHost(node); ASSERT_TRUE(speculative_rfh); EXPECT_TRUE(speculative_rfh->is_loading()); EXPECT_FALSE(node->navigation_request()); // Start a new cross-site navigation to the same-site as the ongoing // navigation. The speculative RFH should still be live and trying // to commit the previous navigation, and we create a NavigationRequest in the // FrameTreeNode. RequestNavigation(node, kUrl3); TestRenderFrameHost* speculative_rfh_2 = GetSpeculativeRenderFrameHost(node); ASSERT_TRUE(speculative_rfh_2); EXPECT_EQ(speculative_rfh_2, speculative_rfh); EXPECT_TRUE(speculative_rfh->is_loading()); EXPECT_TRUE(node->navigation_request()); // The first navigation commits. This should clear up the speculative RFH and // the ongoing NavigationRequest. speculative_rfh->SendNavigate(entry_id, true, kUrl2); EXPECT_FALSE(node->navigation_request()); EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); EXPECT_EQ(speculative_rfh, main_test_rfh()); } } // namespace content
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
09a5aff49fd710348a7d25fb06c4961c504a6ef3
de67a0ac6e3b1753c3515436f1d6f30e60a3a4f1
/ServerConfig.cpp
7eef1bf9b95136c97b81dd849674bf5f0b114cbe
[]
no_license
dyw934854565/winServer
ea1a395fd2c0d77ec797988c02e027abd6e29a32
c4a2a390ec53a491b87748edc7f260ee32eb2923
refs/heads/master
2021-01-10T12:27:31.492066
2016-01-24T12:49:01
2016-01-24T12:49:01
48,543,595
1
0
null
null
null
null
UTF-8
C++
false
false
1,433
cpp
#include "stdafx.h" #include "ServerConfig.h" Config::Config(TCHAR* path) { DWORD dwRet; dwRet = GetCurrentDirectory(PATH_SIZE, this->ServerRoot); if (dwRet == 0) { _tprintf(TEXT("GetCurrentDirectory failed (%d)\n"), GetLastError()); } else if (dwRet > PATH_SIZE) { _tprintf(TEXT("GetCurrentDirectory failed (buffer too small; need %d chars)\n"), dwRet); } else { TCHAR bufferpath[1000]; wsprintfW(bufferpath, TEXT("%s%s"), this->ServerRoot, path); //set default setting wsprintfW(this->DocumentRoot, TEXT("%s%s"), this->ServerRoot, TEXT("\\www")); if (-1 != _waccess(bufferpath, 4)) { //get Port this->Port = GetPrivateProfileInt(TEXT("server"), TEXT("port"), this->getPort(), bufferpath); //get document root GetPrivateProfileString(TEXT("server"), TEXT("DocumentRoot"), this->DocumentRoot, this->DocumentRoot, PATH_SIZE, bufferpath); //get default page GetPrivateProfileString(TEXT("server"), TEXT("DefaultPage"), TEXT("index.html"), this->DefaultPage, PATH_SIZE, bufferpath); } else { cout << "can'not find the server.ini config file, server is created with default setting" << endl; } } } Config::Config() { } Config::~Config() { } int Config::getPort() { return this->Port; } TCHAR* Config::getDocumentRoot() { return this->DocumentRoot; } TCHAR* Config::getServerRoot() { return this->ServerRoot; } TCHAR* Config::getDefaultPage() { return this->DefaultPage; }
[ "duanyuwen@duanyuwen-D2.corp.qihoo.net" ]
duanyuwen@duanyuwen-D2.corp.qihoo.net
85d3e6a3aa183fff11c7b1be0a7460d9ca9656bd
5e6943ef0183cc59ab8392060472ccc561700c24
/src/brick/test/simple_test_tick_clock.cc
55eeef4ead15866f2c06f2ad7b982a29bd2103e6
[]
no_license
israel-Liu/brick
88b7ea62c79fc0fc250a60a482d81543c48ec795
9b4e4011df7c0bdede945d98bcd1e0a5ac535773
refs/heads/master
2022-04-20T10:00:47.049834
2020-04-24T03:32:07
2020-04-24T03:32:07
96,489,912
0
0
null
null
null
null
UTF-8
C++
false
false
735
cc
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "brick/test/simple_test_tick_clock.h" #include "brick/logging.h" namespace base { SimpleTestTickClock::SimpleTestTickClock() = default; SimpleTestTickClock::~SimpleTestTickClock() = default; TimeTicks SimpleTestTickClock::NowTicks() const { AutoLock lock(lock_); return now_ticks_; } void SimpleTestTickClock::Advance(TimeDelta delta) { AutoLock lock(lock_); DCHECK(delta >= TimeDelta()); now_ticks_ += delta; } void SimpleTestTickClock::SetNowTicks(TimeTicks ticks) { AutoLock lock(lock_); now_ticks_ = ticks; } } // namespace base
[ "israel.liu.theForger@gmail.com" ]
israel.liu.theForger@gmail.com
ec8e9d8bb6afcc31d3a91fc76f7d186c64ef1d0a
65ab2e28db5d28092c839465c863ba34dd26f5a1
/demo/activex-demo/server/detectregion.cpp
57849a51308139fe1c8db8ae98c5e40545bcbbf2
[]
no_license
ryder1986/VideoDetection
25e30a8f626f0085e8adc009758deb9bdfff5635
dbf9bf7a9f46be46c08783606e785778a601daf9
refs/heads/master
2020-03-30T06:02:39.159814
2018-10-31T09:54:44
2018-10-31T09:54:44
150,835,241
0
0
null
null
null
null
UTF-8
C++
false
false
3,884
cpp
#include "detectregion.h" #include "c4processor.h" #ifdef WITH_CUDA #include "pvdprocessor.h" #include "fvdprocessor.h" #include "mvdprocessor.h" #endif DetectRegion::DetectRegion(DetectRegionInputData pkt):VdData(pkt),p(NULL) { lock.lock(); int valid=false; // p=new PvdMvncProcessor(); if(private_data.SelectedProcessor==LABLE_PROCESSOR_C4) { p=new PvdC4Processor(pkt.data());valid=true;} if(private_data.SelectedProcessor==LABLE_PROCESSOR_DUMMY) //{ p=new DummyProcessor(private_data.ProcessorData);valid=true;} { p=new DummyProcessor(private_data.ProcessorData);valid=true;} #ifdef WITH_CUDA if(private_data.SelectedProcessor==LABLE_PROCESSOR_PVD) { p=new PvdProcessor(private_data.ProcessorData);valid=true;} if(private_data.SelectedProcessor==LABLE_PROCESSOR_FVD) { p=new FvdProcessor(private_data.ProcessorData);valid=true;} if(private_data.SelectedProcessor==LABLE_PROCESSOR_MVD) { p=new MvdProcessor(private_data.ProcessorData);valid=true;} #endif if(!valid){ prt(info,"processor %s error ,exit",private_data.SelectedProcessor.data()); // exit(0); } detect_rect=reshape_2_rect(private_data.ExpectedAreaVers); lock.unlock(); } DetectRegionOutputData DetectRegion::work(Mat frame) { lock.lock(); JsonPacket rst_r; valid_rect(detect_rect,frame.cols,frame.rows); if(detect_rect.width%2)detect_rect.width--; if(detect_rect.height%2)detect_rect.height--; Mat tmp=frame(detect_rect); if(p &&detect_rect.x>=0&&detect_rect.x<10000 &&detect_rect.y>=0&&detect_rect.y<10000 &&detect_rect.width>0&&detect_rect.width<10000 &&detect_rect.height>0&&detect_rect.height<10000 &&frame.cols>0&&frame.rows>0 ){ #if 1 p->process(tmp,rst_r); #else p->process_whole_pic(frame,rst_r,detect_rect); #endif }else{ prt(info,"err arg"); } // p->process(frame,rst_r); VdRect r(detect_rect.x,detect_rect.y,detect_rect.width,detect_rect.height); JsonPacket dct_rct=r.data(); DetectRegionOutputData rst(rst_r,dct_rct); lock.unlock(); return rst; } void DetectRegion::modify(RequestPkt pkt) { lock.lock(); int op=pkt.Operation; switch(op){ case OP::CHANGE_RECT: { AreaVersJsonDataRequest vs(pkt.Argument); detect_rect=reshape_2_rect(vs.ExpectedAreaVers); private_data.set_points(vs.ExpectedAreaVers); break; } case OP::CHANGE_PROCESSOR: { if(p){ delete p; p=NULL; } ProcessorDataJsonDataRequest sp(pkt.Argument); string pro=sp.SelectedProcessor; //string pro= pkt.Argument.get("SelectedProcessor").to_string(); if(pro==LABLE_PROCESSOR_C4){ p=new PvdC4Processor(sp.ProcessorData); private_data.set_processor(pro,sp.ProcessorData); } if(pro==LABLE_PROCESSOR_DUMMY){ p=new DummyProcessor(sp.ProcessorData); private_data.set_processor(pro,sp.ProcessorData); } #ifdef WITH_CUDA if(pro==LABLE_PROCESSOR_PVD) { p=new PvdProcessor(sp.ProcessorData); private_data.set_processor(pro,sp.ProcessorData); } if(pro==LABLE_PROCESSOR_FVD) { p=new FvdProcessor(sp.ProcessorData); private_data.set_processor(pro,sp.ProcessorData); } if(pro==LABLE_PROCESSOR_MVD) { p=new MvdProcessor(sp.ProcessorData); private_data.set_processor(pro,sp.ProcessorData); } #endif break; } case OP::MODIFY_PROCESSOR: { p-> modify_processor(pkt.Argument); private_data.set_processor_data(pkt.Argument);//TODO:fetch data from processor break; } defalut:break; } lock.unlock(); }
[ "ryder1986@163.com" ]
ryder1986@163.com
99ad44872be4f9af5eb7d83c4a3e6f4588a8971a
fec109cf07ff31e875a52ecda99fc63ace1b541a
/4Sum II.cpp
9bef5684257da88fefbd1a646b869d2715b19983
[]
no_license
ks-kushagra/Leetcode
6d611f305893903d6e3e363757e616432d0331b7
9cdd2a8baa2946400eab6a812e38845917c5a899
refs/heads/master
2023-05-11T17:02:29.752708
2023-05-03T17:33:30
2023-05-03T17:33:30
276,583,205
1
0
null
null
null
null
UTF-8
C++
false
false
1,505
cpp
Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is zero. To make problem a bit easier, all A, B, C, D have same length of N where 0 ≤ N ≤ 500. All integers are in the range of -228 to 228 - 1 and the result is guaranteed to be at most 231 - 1. Example: Input: A = [ 1, 2] B = [-2,-1] C = [-1, 2] D = [ 0, 2] Output: 2 Explanation: The two tuples are: 1. (0, 0, 0, 1) -> A[0] + B[0] + C[0] + D[1] = 1 + (-2) + (-1) + 2 = 0 2. (1, 1, 0, 0) -> A[1] + B[1] + C[0] + D[0] = 2 + (-1) + (-1) + 0 = 0 _______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ class Solution { public: int fourSumCount(vector<int>& A, vector<int>& B, vector<int>& C, vector<int>& D) { unordered_map <int,int> mp1; unordered_map <int,int> mp2; int count=0; int n = A.size(); for(int i=0;i<n;i++) for(int j=0;j<n;j++) { mp1[A[i]+B[j]]++; mp2[C[i]+D[j]]++; } for(auto i =mp1.begin();i!=mp1.end();i++) { if(mp2.find((-1)*(i->first)) != mp2.end()) count += (i->second)*mp2[(-1)*(i->first)]; } return count; } };
[ "noreply@github.com" ]
noreply@github.com
86f1c13585b8b6ae990f34c923a854c29de93224
83bacfbdb7ad17cbc2fc897b3460de1a6726a3b1
/v8_7_5/src/compiler/node-matchers.h
d81d84eca331bd7d7bafaf7377838e7f34500ad8
[ "Apache-2.0", "bzip2-1.0.6", "BSD-3-Clause", "SunPro" ]
permissive
cool2528/miniblink49
d909e39012f2c5d8ab658dc2a8b314ad0050d8ea
7f646289d8074f098cf1244adc87b95e34ab87a8
refs/heads/master
2020-06-05T03:18:43.211372
2019-06-01T08:57:37
2019-06-01T08:59:56
192,294,645
2
0
Apache-2.0
2019-06-17T07:16:28
2019-06-17T07:16:27
null
UTF-8
C++
false
false
26,790
h
// Copyright 2014 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef V8_COMPILER_NODE_MATCHERS_H_ #define V8_COMPILER_NODE_MATCHERS_H_ #include <cmath> #include "src/base/compiler-specific.h" #include "src/compiler/node.h" #include "src/compiler/operator.h" #include "src/double.h" #include "src/external-reference.h" #include "src/globals.h" #include "src/objects/heap-object.h" namespace v8 { namespace internal { namespace compiler { class JSHeapBroker; // A pattern matcher for nodes. struct NodeMatcher { explicit NodeMatcher(Node* node) : node_(node) {} Node* node() const { return node_; } const Operator* op() const { return node()->op(); } IrOpcode::Value opcode() const { return node()->opcode(); } bool HasProperty(Operator::Property property) const { return op()->HasProperty(property); } Node* InputAt(int index) const { return node()->InputAt(index); } bool Equals(const Node* node) const { return node_ == node; } bool IsComparison() const; #define DEFINE_IS_OPCODE(Opcode) \ bool Is##Opcode() const { return opcode() == IrOpcode::k##Opcode; } ALL_OP_LIST(DEFINE_IS_OPCODE) #undef DEFINE_IS_OPCODE private: Node* node_; }; // A pattern matcher for abitrary value constants. template <typename T, IrOpcode::Value kOpcode> struct ValueMatcher : public NodeMatcher { typedef T ValueType; explicit ValueMatcher(Node* node) : NodeMatcher(node), value_(), has_value_(opcode() == kOpcode) { if (has_value_) { value_ = OpParameter<T>(node->op()); } } bool HasValue() const { return has_value_; } const T& Value() const { DCHECK(HasValue()); return value_; } private: T value_; bool has_value_; }; template <> inline ValueMatcher<uint32_t, IrOpcode::kInt32Constant>::ValueMatcher( Node* node) : NodeMatcher(node), value_(), has_value_(opcode() == IrOpcode::kInt32Constant) { if (has_value_) { value_ = static_cast<uint32_t>(OpParameter<int32_t>(node->op())); } } template <> inline ValueMatcher<int64_t, IrOpcode::kInt64Constant>::ValueMatcher(Node* node) : NodeMatcher(node), value_(), has_value_(false) { if (opcode() == IrOpcode::kInt32Constant) { value_ = OpParameter<int32_t>(node->op()); has_value_ = true; } else if (opcode() == IrOpcode::kInt64Constant) { value_ = OpParameter<int64_t>(node->op()); has_value_ = true; } } template <> inline ValueMatcher<uint64_t, IrOpcode::kInt64Constant>::ValueMatcher( Node* node) : NodeMatcher(node), value_(), has_value_(false) { if (opcode() == IrOpcode::kInt32Constant) { value_ = static_cast<uint32_t>(OpParameter<int32_t>(node->op())); has_value_ = true; } else if (opcode() == IrOpcode::kInt64Constant) { value_ = static_cast<uint64_t>(OpParameter<int64_t>(node->op())); has_value_ = true; } } // A pattern matcher for integer constants. template <typename T, IrOpcode::Value kOpcode> struct IntMatcher final : public ValueMatcher<T, kOpcode> { explicit IntMatcher(Node* node) : ValueMatcher<T, kOpcode>(node) {} bool Is(const T& value) const { return this->HasValue() && this->Value() == value; } bool IsInRange(const T& low, const T& high) const { return this->HasValue() && low <= this->Value() && this->Value() <= high; } bool IsMultipleOf(T n) const { return this->HasValue() && (this->Value() % n) == 0; } bool IsPowerOf2() const { return this->HasValue() && this->Value() > 0 && (this->Value() & (this->Value() - 1)) == 0; } bool IsNegativePowerOf2() const { return this->HasValue() && this->Value() < 0 && ((this->Value() == kMinInt) || (-this->Value() & (-this->Value() - 1)) == 0); } bool IsNegative() const { return this->HasValue() && this->Value() < 0; } }; typedef IntMatcher<int32_t, IrOpcode::kInt32Constant> Int32Matcher; typedef IntMatcher<uint32_t, IrOpcode::kInt32Constant> Uint32Matcher; typedef IntMatcher<int64_t, IrOpcode::kInt64Constant> Int64Matcher; typedef IntMatcher<uint64_t, IrOpcode::kInt64Constant> Uint64Matcher; #if V8_HOST_ARCH_32_BIT typedef Int32Matcher IntPtrMatcher; typedef Uint32Matcher UintPtrMatcher; #else typedef Int64Matcher IntPtrMatcher; typedef Uint64Matcher UintPtrMatcher; #endif // A pattern matcher for floating point constants. template <typename T, IrOpcode::Value kOpcode> struct FloatMatcher final : public ValueMatcher<T, kOpcode> { explicit FloatMatcher(Node* node) : ValueMatcher<T, kOpcode>(node) {} bool Is(const T& value) const { return this->HasValue() && this->Value() == value; } bool IsInRange(const T& low, const T& high) const { return this->HasValue() && low <= this->Value() && this->Value() <= high; } bool IsMinusZero() const { return this->Is(0.0) && std::signbit(this->Value()); } bool IsNegative() const { return this->HasValue() && this->Value() < 0.0; } bool IsNaN() const { return this->HasValue() && std::isnan(this->Value()); } bool IsZero() const { return this->Is(0.0) && !std::signbit(this->Value()); } bool IsNormal() const { return this->HasValue() && std::isnormal(this->Value()); } bool IsInteger() const { return this->HasValue() && std::nearbyint(this->Value()) == this->Value(); } bool IsPositiveOrNegativePowerOf2() const { if (!this->HasValue() || (this->Value() == 0.0)) { return false; } Double value = Double(this->Value()); return !value.IsInfinite() && base::bits::IsPowerOfTwo(value.Significand()); } }; typedef FloatMatcher<float, IrOpcode::kFloat32Constant> Float32Matcher; typedef FloatMatcher<double, IrOpcode::kFloat64Constant> Float64Matcher; typedef FloatMatcher<double, IrOpcode::kNumberConstant> NumberMatcher; // A pattern matcher for heap object constants. struct HeapObjectMatcher final : public ValueMatcher<Handle<HeapObject>, IrOpcode::kHeapConstant> { explicit HeapObjectMatcher(Node* node) : ValueMatcher<Handle<HeapObject>, IrOpcode::kHeapConstant>(node) {} bool Is(Handle<HeapObject> const& value) const { return this->HasValue() && this->Value().address() == value.address(); } ObjectRef Ref(JSHeapBroker* broker) const { return ObjectRef(broker, this->Value()); } }; // A pattern matcher for external reference constants. struct ExternalReferenceMatcher final : public ValueMatcher<ExternalReference, IrOpcode::kExternalConstant> { explicit ExternalReferenceMatcher(Node* node) : ValueMatcher<ExternalReference, IrOpcode::kExternalConstant>(node) {} bool Is(const ExternalReference& value) const { return this->HasValue() && this->Value() == value; } }; // For shorter pattern matching code, this struct matches the inputs to // machine-level load operations. template <typename Object> struct LoadMatcher : public NodeMatcher { explicit LoadMatcher(Node* node) : NodeMatcher(node), object_(InputAt(0)), index_(InputAt(1)) {} typedef Object ObjectMatcher; Object const& object() const { return object_; } IntPtrMatcher const& index() const { return index_; } private: Object const object_; IntPtrMatcher const index_; }; // For shorter pattern matching code, this struct matches both the left and // right hand sides of a binary operation and can put constants on the right // if they appear on the left hand side of a commutative operation. template <typename Left, typename Right> struct BinopMatcher : public NodeMatcher { explicit BinopMatcher(Node* node) : NodeMatcher(node), left_(InputAt(0)), right_(InputAt(1)) { if (HasProperty(Operator::kCommutative)) PutConstantOnRight(); } BinopMatcher(Node* node, bool allow_input_swap) : NodeMatcher(node), left_(InputAt(0)), right_(InputAt(1)) { if (allow_input_swap) PutConstantOnRight(); } typedef Left LeftMatcher; typedef Right RightMatcher; const Left& left() const { return left_; } const Right& right() const { return right_; } bool IsFoldable() const { return left().HasValue() && right().HasValue(); } bool LeftEqualsRight() const { return left().node() == right().node(); } protected: void SwapInputs() { std::swap(left_, right_); // TODO(tebbi): This modification should notify the reducers using // BinopMatcher. Alternatively, all reducers (especially value numbering) // could ignore the ordering for commutative binops. node()->ReplaceInput(0, left().node()); node()->ReplaceInput(1, right().node()); } private: void PutConstantOnRight() { if (left().HasValue() && !right().HasValue()) { SwapInputs(); } } Left left_; Right right_; }; typedef BinopMatcher<Int32Matcher, Int32Matcher> Int32BinopMatcher; typedef BinopMatcher<Uint32Matcher, Uint32Matcher> Uint32BinopMatcher; typedef BinopMatcher<Int64Matcher, Int64Matcher> Int64BinopMatcher; typedef BinopMatcher<Uint64Matcher, Uint64Matcher> Uint64BinopMatcher; typedef BinopMatcher<IntPtrMatcher, IntPtrMatcher> IntPtrBinopMatcher; typedef BinopMatcher<UintPtrMatcher, UintPtrMatcher> UintPtrBinopMatcher; typedef BinopMatcher<Float32Matcher, Float32Matcher> Float32BinopMatcher; typedef BinopMatcher<Float64Matcher, Float64Matcher> Float64BinopMatcher; typedef BinopMatcher<NumberMatcher, NumberMatcher> NumberBinopMatcher; typedef BinopMatcher<HeapObjectMatcher, HeapObjectMatcher> HeapObjectBinopMatcher; template <class BinopMatcher, IrOpcode::Value kMulOpcode, IrOpcode::Value kShiftOpcode> struct ScaleMatcher { explicit ScaleMatcher(Node* node, bool allow_power_of_two_plus_one = false) : scale_(-1), power_of_two_plus_one_(false) { if (node->InputCount() < 2) return; BinopMatcher m(node); if (node->opcode() == kShiftOpcode) { if (m.right().HasValue()) { typename BinopMatcher::RightMatcher::ValueType value = m.right().Value(); if (value >= 0 && value <= 3) { scale_ = static_cast<int>(value); } } } else if (node->opcode() == kMulOpcode) { if (m.right().HasValue()) { typename BinopMatcher::RightMatcher::ValueType value = m.right().Value(); if (value == 1) { scale_ = 0; } else if (value == 2) { scale_ = 1; } else if (value == 4) { scale_ = 2; } else if (value == 8) { scale_ = 3; } else if (allow_power_of_two_plus_one) { if (value == 3) { scale_ = 1; power_of_two_plus_one_ = true; } else if (value == 5) { scale_ = 2; power_of_two_plus_one_ = true; } else if (value == 9) { scale_ = 3; power_of_two_plus_one_ = true; } } } } } bool matches() const { return scale_ != -1; } int scale() const { return scale_; } bool power_of_two_plus_one() const { return power_of_two_plus_one_; } private: int scale_; bool power_of_two_plus_one_; }; typedef ScaleMatcher<Int32BinopMatcher, IrOpcode::kInt32Mul, IrOpcode::kWord32Shl> Int32ScaleMatcher; typedef ScaleMatcher<Int64BinopMatcher, IrOpcode::kInt64Mul, IrOpcode::kWord64Shl> Int64ScaleMatcher; template <class BinopMatcher, IrOpcode::Value AddOpcode, IrOpcode::Value SubOpcode, IrOpcode::Value kMulOpcode, IrOpcode::Value kShiftOpcode> struct AddMatcher : public BinopMatcher { static const IrOpcode::Value kAddOpcode = AddOpcode; static const IrOpcode::Value kSubOpcode = SubOpcode; typedef ScaleMatcher<BinopMatcher, kMulOpcode, kShiftOpcode> Matcher; AddMatcher(Node* node, bool allow_input_swap) : BinopMatcher(node, allow_input_swap), scale_(-1), power_of_two_plus_one_(false) { Initialize(node, allow_input_swap); } explicit AddMatcher(Node* node) : BinopMatcher(node, node->op()->HasProperty(Operator::kCommutative)), scale_(-1), power_of_two_plus_one_(false) { Initialize(node, node->op()->HasProperty(Operator::kCommutative)); } bool HasIndexInput() const { return scale_ != -1; } Node* IndexInput() const { DCHECK(HasIndexInput()); return this->left().node()->InputAt(0); } int scale() const { DCHECK(HasIndexInput()); return scale_; } bool power_of_two_plus_one() const { return power_of_two_plus_one_; } private: void Initialize(Node* node, bool allow_input_swap) { Matcher left_matcher(this->left().node(), true); if (left_matcher.matches()) { scale_ = left_matcher.scale(); power_of_two_plus_one_ = left_matcher.power_of_two_plus_one(); return; } if (!allow_input_swap) { return; } Matcher right_matcher(this->right().node(), true); if (right_matcher.matches()) { scale_ = right_matcher.scale(); power_of_two_plus_one_ = right_matcher.power_of_two_plus_one(); this->SwapInputs(); return; } if ((this->left().opcode() != kSubOpcode && this->left().opcode() != kAddOpcode) && (this->right().opcode() == kAddOpcode || this->right().opcode() == kSubOpcode)) { this->SwapInputs(); } } int scale_; bool power_of_two_plus_one_; }; typedef AddMatcher<Int32BinopMatcher, IrOpcode::kInt32Add, IrOpcode::kInt32Sub, IrOpcode::kInt32Mul, IrOpcode::kWord32Shl> Int32AddMatcher; typedef AddMatcher<Int64BinopMatcher, IrOpcode::kInt64Add, IrOpcode::kInt64Sub, IrOpcode::kInt64Mul, IrOpcode::kWord64Shl> Int64AddMatcher; enum DisplacementMode { kPositiveDisplacement, kNegativeDisplacement }; enum class AddressOption : uint8_t { kAllowNone = 0u, kAllowInputSwap = 1u << 0, kAllowScale = 1u << 1, kAllowAll = kAllowInputSwap | kAllowScale }; typedef base::Flags<AddressOption, uint8_t> AddressOptions; DEFINE_OPERATORS_FOR_FLAGS(AddressOptions) template <class AddMatcher> struct BaseWithIndexAndDisplacementMatcher { BaseWithIndexAndDisplacementMatcher(Node* node, AddressOptions options) : matches_(false), index_(nullptr), scale_(0), base_(nullptr), displacement_(nullptr), displacement_mode_(kPositiveDisplacement) { Initialize(node, options); } explicit BaseWithIndexAndDisplacementMatcher(Node* node) : matches_(false), index_(nullptr), scale_(0), base_(nullptr), displacement_(nullptr), displacement_mode_(kPositiveDisplacement) { Initialize(node, AddressOption::kAllowScale | (node->op()->HasProperty(Operator::kCommutative) ? AddressOption::kAllowInputSwap : AddressOption::kAllowNone)); } bool matches() const { return matches_; } Node* index() const { return index_; } int scale() const { return scale_; } Node* base() const { return base_; } Node* displacement() const { return displacement_; } DisplacementMode displacement_mode() const { return displacement_mode_; } private: bool matches_; Node* index_; int scale_; Node* base_; Node* displacement_; DisplacementMode displacement_mode_; void Initialize(Node* node, AddressOptions options) { // The BaseWithIndexAndDisplacementMatcher canonicalizes the order of // displacements and scale factors that are used as inputs, so instead of // enumerating all possible patterns by brute force, checking for node // clusters using the following templates in the following order suffices to // find all of the interesting cases (S = index * scale, B = base input, D = // displacement input): // (S + (B + D)) // (S + (B + B)) // (S + D) // (S + B) // ((S + D) + B) // ((S + B) + D) // ((B + D) + B) // ((B + B) + D) // (B + D) // (B + B) if (node->InputCount() < 2) return; AddMatcher m(node, options & AddressOption::kAllowInputSwap); Node* left = m.left().node(); Node* right = m.right().node(); Node* displacement = nullptr; Node* base = nullptr; Node* index = nullptr; Node* scale_expression = nullptr; bool power_of_two_plus_one = false; DisplacementMode displacement_mode = kPositiveDisplacement; int scale = 0; if (m.HasIndexInput() && OwnedByAddressingOperand(left)) { index = m.IndexInput(); scale = m.scale(); scale_expression = left; power_of_two_plus_one = m.power_of_two_plus_one(); bool match_found = false; if (right->opcode() == AddMatcher::kSubOpcode && OwnedByAddressingOperand(right)) { AddMatcher right_matcher(right); if (right_matcher.right().HasValue()) { // (S + (B - D)) base = right_matcher.left().node(); displacement = right_matcher.right().node(); displacement_mode = kNegativeDisplacement; match_found = true; } } if (!match_found) { if (right->opcode() == AddMatcher::kAddOpcode && OwnedByAddressingOperand(right)) { AddMatcher right_matcher(right); if (right_matcher.right().HasValue()) { // (S + (B + D)) base = right_matcher.left().node(); displacement = right_matcher.right().node(); } else { // (S + (B + B)) base = right; } } else if (m.right().HasValue()) { // (S + D) displacement = right; } else { // (S + B) base = right; } } } else { bool match_found = false; if (left->opcode() == AddMatcher::kSubOpcode && OwnedByAddressingOperand(left)) { AddMatcher left_matcher(left); Node* left_left = left_matcher.left().node(); Node* left_right = left_matcher.right().node(); if (left_matcher.right().HasValue()) { if (left_matcher.HasIndexInput() && left_left->OwnedBy(left)) { // ((S - D) + B) index = left_matcher.IndexInput(); scale = left_matcher.scale(); scale_expression = left_left; power_of_two_plus_one = left_matcher.power_of_two_plus_one(); displacement = left_right; displacement_mode = kNegativeDisplacement; base = right; } else { // ((B - D) + B) index = left_left; displacement = left_right; displacement_mode = kNegativeDisplacement; base = right; } match_found = true; } } if (!match_found) { if (left->opcode() == AddMatcher::kAddOpcode && OwnedByAddressingOperand(left)) { AddMatcher left_matcher(left); Node* left_left = left_matcher.left().node(); Node* left_right = left_matcher.right().node(); if (left_matcher.HasIndexInput() && left_left->OwnedBy(left)) { if (left_matcher.right().HasValue()) { // ((S + D) + B) index = left_matcher.IndexInput(); scale = left_matcher.scale(); scale_expression = left_left; power_of_two_plus_one = left_matcher.power_of_two_plus_one(); displacement = left_right; base = right; } else if (m.right().HasValue()) { if (left->OwnedBy(node)) { // ((S + B) + D) index = left_matcher.IndexInput(); scale = left_matcher.scale(); scale_expression = left_left; power_of_two_plus_one = left_matcher.power_of_two_plus_one(); base = left_right; displacement = right; } else { // (B + D) base = left; displacement = right; } } else { // (B + B) index = left; base = right; } } else { if (left_matcher.right().HasValue()) { // ((B + D) + B) index = left_left; displacement = left_right; base = right; } else if (m.right().HasValue()) { if (left->OwnedBy(node)) { // ((B + B) + D) index = left_left; base = left_right; displacement = right; } else { // (B + D) base = left; displacement = right; } } else { // (B + B) index = left; base = right; } } } else { if (m.right().HasValue()) { // (B + D) base = left; displacement = right; } else { // (B + B) base = left; index = right; } } } } int64_t value = 0; if (displacement != nullptr) { switch (displacement->opcode()) { case IrOpcode::kInt32Constant: { value = OpParameter<int32_t>(displacement->op()); break; } case IrOpcode::kInt64Constant: { value = OpParameter<int64_t>(displacement->op()); break; } default: UNREACHABLE(); break; } if (value == 0) { displacement = nullptr; } } if (power_of_two_plus_one) { if (base != nullptr) { // If the scale requires explicitly using the index as the base, but a // base is already part of the match, then the (1 << N + 1) scale factor // can't be folded into the match and the entire index * scale // calculation must be computed separately. index = scale_expression; scale = 0; } else { base = index; } } if (!(options & AddressOption::kAllowScale) && scale != 0) { index = scale_expression; scale = 0; } base_ = base; displacement_ = displacement; displacement_mode_ = displacement_mode; index_ = index; scale_ = scale; matches_ = true; } static bool OwnedByAddressingOperand(Node* node) { for (auto use : node->use_edges()) { Node* from = use.from(); switch (from->opcode()) { case IrOpcode::kLoad: case IrOpcode::kPoisonedLoad: case IrOpcode::kProtectedLoad: case IrOpcode::kInt32Add: case IrOpcode::kInt64Add: // Skip addressing uses. break; case IrOpcode::kStore: case IrOpcode::kProtectedStore: // If the stored value is this node, it is not an addressing use. if (from->InputAt(2) == node) return false; // Otherwise it is used as an address and skipped. break; default: // Non-addressing use found. return false; } } return true; } }; typedef BaseWithIndexAndDisplacementMatcher<Int32AddMatcher> BaseWithIndexAndDisplacement32Matcher; typedef BaseWithIndexAndDisplacementMatcher<Int64AddMatcher> BaseWithIndexAndDisplacement64Matcher; struct V8_EXPORT_PRIVATE BranchMatcher : public NON_EXPORTED_BASE(NodeMatcher) { explicit BranchMatcher(Node* branch); bool Matched() const { return if_true_ && if_false_; } Node* Branch() const { return node(); } Node* IfTrue() const { return if_true_; } Node* IfFalse() const { return if_false_; } private: Node* if_true_; Node* if_false_; }; struct V8_EXPORT_PRIVATE DiamondMatcher : public NON_EXPORTED_BASE(NodeMatcher) { explicit DiamondMatcher(Node* merge); bool Matched() const { return branch_; } bool IfProjectionsAreOwned() const { return if_true_->OwnedBy(node()) && if_false_->OwnedBy(node()); } Node* Branch() const { return branch_; } Node* IfTrue() const { return if_true_; } Node* IfFalse() const { return if_false_; } Node* Merge() const { return node(); } Node* TrueInputOf(Node* phi) const { DCHECK(IrOpcode::IsPhiOpcode(phi->opcode())); DCHECK_EQ(3, phi->InputCount()); DCHECK_EQ(Merge(), phi->InputAt(2)); return phi->InputAt(if_true_ == Merge()->InputAt(0) ? 0 : 1); } Node* FalseInputOf(Node* phi) const { DCHECK(IrOpcode::IsPhiOpcode(phi->opcode())); DCHECK_EQ(3, phi->InputCount()); DCHECK_EQ(Merge(), phi->InputAt(2)); return phi->InputAt(if_true_ == Merge()->InputAt(0) ? 1 : 0); } private: Node* branch_; Node* if_true_; Node* if_false_; }; template <class BinopMatcher, IrOpcode::Value expected_opcode> struct WasmStackCheckMatcher { explicit WasmStackCheckMatcher(Node* compare) : compare_(compare) {} bool Matched() { if (compare_->opcode() != expected_opcode) return false; BinopMatcher m(compare_); return MatchedInternal(m.left(), m.right()); } private: bool MatchedInternal(const typename BinopMatcher::LeftMatcher& l, const typename BinopMatcher::RightMatcher& r) { // In wasm, the stack check is performed by loading the value given by // the address of a field stored in the instance object. That object is // passed as a parameter. if (l.IsLoad() && r.IsLoadStackPointer()) { LoadMatcher<LoadMatcher<NodeMatcher>> mleft(l.node()); if (mleft.object().IsLoad() && mleft.index().Is(0) && mleft.object().object().IsParameter()) { return true; } } return false; } Node* compare_; }; template <class BinopMatcher, IrOpcode::Value expected_opcode> struct StackCheckMatcher { StackCheckMatcher(Isolate* isolate, Node* compare) : isolate_(isolate), compare_(compare) { DCHECK_NOT_NULL(isolate); } bool Matched() { // TODO(jgruber): Ideally, we could be more flexible here and also match the // same pattern with switched operands (i.e.: left is LoadStackPointer and // right is the js_stack_limit load). But to be correct in all cases, we'd // then have to invert the outcome of the stack check comparison. if (compare_->opcode() != expected_opcode) return false; BinopMatcher m(compare_); return MatchedInternal(m.left(), m.right()); } private: bool MatchedInternal(const typename BinopMatcher::LeftMatcher& l, const typename BinopMatcher::RightMatcher& r) { if (l.IsLoad() && r.IsLoadStackPointer()) { LoadMatcher<ExternalReferenceMatcher> mleft(l.node()); ExternalReference js_stack_limit = ExternalReference::address_of_stack_limit(isolate_); if (mleft.object().Is(js_stack_limit) && mleft.index().Is(0)) return true; } return false; } Isolate* isolate_; Node* compare_; }; } // namespace compiler } // namespace internal } // namespace v8 #endif // V8_COMPILER_NODE_MATCHERS_H_
[ "22249030@qq.com" ]
22249030@qq.com
866fea53121ef23b1a50773a0766668075417a27
76dd374a5ebe93b6bbeaa61ea2e600ac7f23cf1d
/3rdParty/boost/1.61.0/libs/hana/benchmark/difference/compile.hana.set.erb.cpp
5764d6ebcad570d21dc3d018698f2e4e912d1a1d
[ "Apache-2.0", "BSD-3-Clause", "Zlib", "ISC", "LicenseRef-scancode-proprietary-license", "MIT", "BSL-1.0", "LicenseRef-scancode-unknown-license-reference", "Unlicense", "ICU" ]
permissive
mikestaub/arangodb
5064eaab8b4587dccc7ea9982e3fea4c926eb620
1bdf414de29b31bcaf80769a095933f66f8256ce
refs/heads/devel
2021-08-10T15:44:03.423137
2016-09-23T13:23:03
2016-09-23T13:23:03
69,112,437
1
0
Apache-2.0
2021-01-21T15:29:30
2016-09-24T16:02:10
C++
UTF-8
C++
false
false
659
cpp
// Copyright Louis Dionne 2013-2016 // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) #include <boost/hana/difference.hpp> #include <boost/hana/integral_constant.hpp> #include <boost/hana/set.hpp> namespace hana = boost::hana; int main() { constexpr auto xs = hana::make_set( <%= (1..input_size).map { |n| "hana::int_c<#{n}>" }.join(', ') %> ); constexpr auto ys = hana::make_set( <%= (1..(input_size/2)).map { |n| "hana::int_c<#{n}>" }.join(', ') %> ); constexpr auto result = hana::difference(xs, ys); (void)result; }
[ "frank@arangodb.com" ]
frank@arangodb.com
a75856803864da07ac9ca4d08508016b1d7ed6f2
5ab8589e28cf9b24a62a466437fdb124b27e05c6
/PaintAndSend/TextLabel.cpp
a278fea4d128321493e53da989a2553f034ef9a0
[]
no_license
pavelseps/PaintAndSend
0cd2e6e29dcc182d2ea32fdab408a0e14055c1ac
672c55b346a3f38838f72a31a8440d999694c052
refs/heads/master
2021-01-01T15:28:29.264599
2017-07-24T19:03:17
2017-07-24T19:03:17
97,625,974
0
0
null
null
null
null
UTF-8
C++
false
false
1,555
cpp
#include "stdafx.h" #include "TextLabel.h" TextLabel::TextLabel(sf::Vector2f &coords, sf::Vector2f &size, sf::Font &font) { input.setFont(font); input.setFillColor(sf::Color::Black); input.setCharacterSize(size.y - (padding * 2)); input.setPosition(sf::Vector2f(coords.x + padding, coords.y + padding - 2)); input.setString(""); background.setFillColor(sf::Color::Black); background.setSize(size); background.setPosition(coords); } TextLabel::~TextLabel() { } void TextLabel::setText(std::string s) { input.setString(s); } std::string TextLabel::getText() { return input.getString(); } void TextLabel::setBackgroundColor(sf::Color c) { background.setFillColor(c); } void TextLabel::setTextColor(sf::Color c) { input.setFillColor(c); } void TextLabel::setCoords(sf::Vector2f &coords) { input.setPosition(sf::Vector2f(coords.x, coords.y + 15));; background.setPosition(coords.x, coords.y + 15); } void TextLabel::setSize(sf::Vector2f &size) { input.setCharacterSize(size.y); background.setSize(size); } bool TextLabel::isFocused(int mouseX, int mouseY) { return mouseX > background.getPosition().x && mouseY > background.getPosition().y && mouseX < (background.getSize().x + background.getPosition().x) && mouseY < (background.getSize().y + background.getPosition().y); } void TextLabel::draw(sf::RenderTarget& target, sf::RenderStates states) const { target.draw(background, states); target.draw(input, states); } void TextLabel::setId(std::string s) { this->id = s; } std::string TextLabel::getId() { return this->id; }
[ "pavel.seps@layoutmaschine.de" ]
pavel.seps@layoutmaschine.de
eabaf91ac5c55d9d3bd5149ea15aa1b183550d53
78414d72fd2f8db9cd82e41a5d48267e52f01368
/HedgeGI/HedgeGI/Bitmap.cpp
3cc3db717481d130b3deae99a12e0db78926ba2c
[]
no_license
iulian204/HedgeGI
16be98a4f0230ee3d1d3a42ce9eee137ff50f93c
9989c0950ba1b6cc3ee8baa8d56721565af9517e
refs/heads/master
2022-10-11T16:05:45.847776
2020-06-09T23:57:35
2020-06-09T23:57:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,559
cpp
#include "Bitmap.h" Bitmap::Bitmap() = default; Bitmap::Bitmap(const uint32_t width, const uint32_t height, const uint32_t arraySize) : width(width), height(height), arraySize(arraySize), data(std::make_unique<Eigen::Array4f[]>(width * height * arraySize)) { for (size_t i = 0; i < width * height * arraySize; i++) data[i] = Eigen::Vector4f::Zero(); } void Bitmap::getPixelCoords(const Eigen::Vector2f& uv, uint32_t& x, uint32_t& y) const { const Eigen::Vector2f clamped = clampUV(uv); x = std::max(0u, std::min(width - 1, (uint32_t)std::roundf(clamped[0] * width))); y = std::max(0u, std::min(height - 1, (uint32_t)std::roundf(clamped[1] * height))); } Eigen::Array4f Bitmap::pickColor(const Eigen::Vector2f& uv, const uint32_t arrayIndex) const { uint32_t x, y; getPixelCoords(uv, x, y); return data[width * height * arrayIndex + y * width + x]; } Eigen::Array4f Bitmap::pickColor(const uint32_t x, const uint32_t y, const uint32_t arrayIndex) const { return data[width * height * arrayIndex + std::max(0u, std::min(height - 1, y)) * width + std::max(0u, std::min(width - 1, x))]; } void Bitmap::putColor(const Eigen::Array4f& color, const Eigen::Vector2f& uv, const uint32_t arrayIndex) const { uint32_t x, y; getPixelCoords(uv, x, y); data[width * height * arrayIndex + y * width + x] = color; } void Bitmap::putColor(const Eigen::Array4f& color, const uint32_t x, const uint32_t y, const uint32_t arrayIndex) const { data[width * height * arrayIndex + std::max(0u, std::min(height - 1, y)) * width + std::max(0u, std::min(width - 1, x))] = color; } void Bitmap::read(const FileStream& file) { name = file.readString(); width = file.read<uint32_t>(); height = file.read<uint32_t>(); arraySize = file.read<uint32_t>(); data = std::make_unique<Eigen::Array4f[]>(width * height * arraySize); file.read(data.get(), width * height * arraySize); } void Bitmap::write(const FileStream& file) const { file.write(name); file.write(width); file.write(height); file.write(arraySize); file.write(data.get(), width * height * arraySize); } void Bitmap::save(const std::string& filePath) const { DirectX::ScratchImage scratchImage; { DirectX::ScratchImage victimScratchImage; victimScratchImage.Initialize2D(DXGI_FORMAT_R32G32B32A32_FLOAT, width, height, arraySize, 1); for (uint32_t i = 0; i < arraySize; i++) memcpy(victimScratchImage.GetImage(0, i, 0)->pixels, &data[width * height * i], width * height * sizeof(Eigen::Vector4f)); Convert(victimScratchImage.GetImages(), victimScratchImage.GetImageCount(), victimScratchImage.GetMetadata(), DXGI_FORMAT_R16G16B16A16_UNORM, DirectX::TEX_FILTER_DEFAULT, DirectX::TEX_THRESHOLD_DEFAULT, scratchImage); } WCHAR wideCharFilePath[MAX_PATH]; MultiByteToWideChar(CP_UTF8, NULL, filePath.c_str(), -1, wideCharFilePath, MAX_PATH); SaveToWICFile(scratchImage.GetImages(), scratchImage.GetImageCount(), DirectX::WIC_FLAGS_FORCE_LINEAR, GetWICCodec(DirectX::WIC_CODEC_PNG), wideCharFilePath); } void Bitmap::save(const std::string& filePath, const DXGI_FORMAT format) const { DirectX::ScratchImage scratchImage; { DirectX::ScratchImage victimScratchImage; victimScratchImage.Initialize2D(DXGI_FORMAT_R32G32B32A32_FLOAT, width, height, arraySize, 1); for (uint32_t i = 0; i < arraySize; i++) memcpy(victimScratchImage.GetImage(0, i, 0)->pixels, &data[width * height * i], width * height * sizeof(Eigen::Vector4f)); if (format == DXGI_FORMAT_R32G32B32A32_FLOAT) { std::swap(scratchImage, victimScratchImage); } else if (DirectX::IsCompressed(format)) { Compress(victimScratchImage.GetImages(), victimScratchImage.GetImageCount(), victimScratchImage.GetMetadata(), format, DirectX::TEX_COMPRESS_DEFAULT, DirectX::TEX_THRESHOLD_DEFAULT, scratchImage); } else { Convert(victimScratchImage.GetImages(), victimScratchImage.GetImageCount(), victimScratchImage.GetMetadata(), format, DirectX::TEX_FILTER_DEFAULT, DirectX::TEX_THRESHOLD_DEFAULT,scratchImage); } } WCHAR wideCharFilePath[MAX_PATH]; MultiByteToWideChar(CP_UTF8, NULL, filePath.c_str(), -1, wideCharFilePath, MAX_PATH); SaveToDDSFile(scratchImage.GetImages(), scratchImage.GetImageCount(), scratchImage.GetMetadata(), DirectX::DDS_FLAGS_NONE, wideCharFilePath); }
[ "19259897+blueskythlikesclouds@users.noreply.github.com" ]
19259897+blueskythlikesclouds@users.noreply.github.com
1ea406ec6ce46ece9986e34ce3b3f1b6523d5e9a
fd75230595e07ac4aff7bb3b206f260937fcfeba
/complex_crawler/crawler/task/GeneralCrawlTask.cpp
e8913cb3b61e0d14b0a4bf7a0a020f2824a1a870
[ "Apache-2.0", "MIT" ]
permissive
AlaoPrado/search_engine
09a53cfe47c8bbb50c8f41b559021cceee6be71f
6be1f0beb95ca23c5979e60d55a10eeb4fbc1aa1
refs/heads/main
2023-03-12T15:25:32.777171
2021-02-25T15:57:26
2021-02-25T15:57:26
319,131,397
0
0
null
null
null
null
UTF-8
C++
false
false
5,611
cpp
/* Copyright 2021 Alan Prado Araújo Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Author: alanpradoaraujo@gmail.com (Alan Prado Araújo) */ #include "GeneralCrawlTask.hpp" #include "../Page.hpp" #include "../SiteAttributes.hpp" #include "../action/Crawl.hpp" #include "../action/PageStorage.hpp" #include "../action/PopFromScheduler.hpp" #include "../action/PushIntoScheduler.hpp" #include "../scheduler/PageScheduler.hpp" #include <CkSpider.h> #include <cstddef> #include <iostream> #include <map> #include <string> #include <vector> namespace search_engine { GeneralCrawlTask::GeneralCrawlTask() : storageDirectory(""), mustMatchPatterns(NULL), avoidPatterns(NULL), numPagesToCrawl(0), allNumPagesToCrawl(NULL), pageScheduler(NULL), viewedUrls(NULL), siteAttributesMap(NULL), lastCrawlEndTimeMap(NULL), popMutex(NULL), storeMutex(NULL), pushMutex(NULL), memoryMutex(NULL), failMutex(NULL), counterFlag(NULL), threadId(0) {} GeneralCrawlTask::~GeneralCrawlTask() {} void GeneralCrawlTask::set( std::string storageDirectory, std::vector<std::string> *mustMatchPatterns, std::vector<std::string> *avoidPatterns, std::size_t initialNumPageToCrawl, std::size_t numPagesToCrawl, std::size_t *allNumPagesToCrawl, SynchonizedPageGroupScheduler *pageScheduler, std::map<std::string, bool> *viewedUrls, std::map<std::string, SiteAttributes> *siteAttributesMap, std::map<std::string, Crawl::timePoint> *lastCrawlEndTimeMap, pthread_mutex_t *popMutex, pthread_mutex_t *storeMutex, pthread_mutex_t *pushMutex, pthread_mutex_t *memoryMutex, pthread_mutex_t *failMutex, CounterFlag *counterFlag, int threadId) { this->storageDirectory = storageDirectory; this->mustMatchPatterns = mustMatchPatterns; this->avoidPatterns = avoidPatterns; this->initialNumPageToCrawl = initialNumPageToCrawl; this->numPagesToCrawl = numPagesToCrawl; this->allNumPagesToCrawl = allNumPagesToCrawl; this->pageScheduler = pageScheduler; this->viewedUrls = viewedUrls; this->siteAttributesMap = siteAttributesMap; this->lastCrawlEndTimeMap = lastCrawlEndTimeMap; this->popMutex = popMutex; this->storeMutex = storeMutex; this->pushMutex = pushMutex; this->memoryMutex = memoryMutex; this->failMutex = failMutex; this->counterFlag = counterFlag; this->threadId = threadId; } void GeneralCrawlTask::run() { std::size_t numCrawledPages = 0; int numPagesPushed = 0; // std::cout << "Thread " << threadId << std::endl; while (numCrawledPages < numPagesToCrawl) { Page page(""); std::string baseUrl; bool useLastCrawlEndTime; std::cout << "Await " + std::to_string(threadId) + " size: " + std::to_string(pageScheduler->size()) << std::endl; PopFromScheduler::pop(*pageScheduler, page, baseUrl, useLastCrawlEndTime, *siteAttributesMap, *lastCrawlEndTimeMap, memoryMutex, popMutex); std::cout << "Pop " + std::to_string(threadId) + " " + page.getUrl() << std::endl; CkSpider spider; SiteAttributes *siteAttributes = &(siteAttributesMap->operator[](baseUrl)); Crawl::timePoint *lastCrawlEndTime = &(lastCrawlEndTimeMap->operator[](baseUrl)); try { Crawl::crawlUrl(spider, page, *mustMatchPatterns, *avoidPatterns, *siteAttributes, *lastCrawlEndTime, useLastCrawlEndTime); std::cout << "Finish " + std::to_string(threadId) + " " + page.getUrl() << std::endl; PageStorage::storePage(storageDirectory, spider, initialNumPageToCrawl + numCrawledPages, storeMutex); numCrawledPages++; std::cout << "Success: " + page.getUrl() << std::endl; // std::cout << "allNumPagesToCrawl: " << *allNumPagesToCrawl << // std::endl; PushIntoScheduler::push(*pageScheduler, spider, *viewedUrls, *allNumPagesToCrawl, page.getLevel(), numPagesPushed, memoryMutex, pushMutex); if (page.getLevel() == 0) { siteAttributes->addNumPagesLevel1(numPagesPushed); } // std::cout << "numPagesPushed: " << numPagesPushed << std::endl; } catch (std::exception &e) { std::cout << "Error while crawling page " + page.getUrl() << std::endl; std::cout << e.what() << std::endl; pthread_mutex_lock(failMutex); (*allNumPagesToCrawl)++; pthread_mutex_unlock(failMutex); } pageScheduler->finishWork(page.getUrl()); } counterFlag->signal(); } } // namespace search_engine
[ "alanpradoaraujo@gmail.com" ]
alanpradoaraujo@gmail.com
5fc552f851d81bf796fabbb95e6c51cf18ff1fd5
15fa4009e4087a9270b857b4fa155d929c81cb37
/MANA3DEngine/MANA3DEngine/Math3D.h
0d04d3d0c3f807d453c90a2e56385dc6a415a74c
[]
no_license
MANA3DGames/mana-3d-game-engine-public
1464f52ae99a2912b57db57578882aa8793f7b09
ae1430c8369e7cca1f84b1cc42927ec009565c1f
refs/heads/master
2022-12-11T04:39:03.460071
2020-09-02T13:47:11
2020-09-02T13:47:11
292,292,187
1
0
null
null
null
null
UTF-8
C++
false
false
2,165
h
#ifndef MATH3D_H #define MATH3D_H #include <glm\glm.hpp> #include <glm/gtx/quaternion.hpp> #include <glm/gtc/matrix_transform.hpp> #include <glm/gtx/matrix_decompose.hpp> #include <glm/gtc/type_ptr.hpp> #include <assimp/matrix4x4.h> //# define M_PI 3.14159265358979323846 namespace MANA3D { class Math3D { public: static glm::vec3 Normalize( const glm::vec3& ); static glm::vec3 Cross( const glm::vec3& v1, const glm::vec3& v2 ); static glm::vec3 GetPointAtDistance( const glm::vec3& sourcePoint, const glm::vec3& direction, const float& distance ); static glm::quat LookRotation( const glm::vec3& lookAt, const glm::vec3& upDirection ); ///*template <typename RM, typename CM> //static void ConvertToMat4( const RM& from, CM& to );*/ //// copy from Row-major to Column major matrix //// i.e. from aiMatrix4x4 to glm::mat4 //template <typename RM, typename CM> //static void ConvertToMat4( const RM& from, CM& to ) //{ // to[0][0] = from.a1; to[1][0] = from.a2; // to[2][0] = from.a3; to[3][0] = from.a4; // to[0][1] = from.b1; to[1][1] = from.b2; // to[2][1] = from.b3; to[3][1] = from.b4; // to[0][2] = from.c1; to[1][2] = from.c2; // to[2][2] = from.c3; to[3][2] = from.c4; // to[0][3] = from.d1; to[1][3] = from.d2; // to[2][3] = from.d3; to[3][3] = from.d4; //} static void ConvertToMat4( const aiMatrix4x4& from, glm::mat4& to ); static const glm::vec3 VECTOR3_ZERO; // Shorthand for writing Vector3( 0, 0, 0 ). static const glm::vec3 VECTOR3_ONE; // Shorthand for writing Vector3( 1, 1, 1 ). static const glm::vec3 VECTOR3_UP; // Shorthand for writing Vector3( 0, 1, 0 ). static const glm::vec3 VECTOR3_DOWN; // Shorthand for writing Vector3( 0, -1, 0 ). static const glm::vec3 VECTOR3_RIGHT; // Shorthand for writing Vector3( 1, 0, 0 ). static const glm::vec3 VECTOR3_LEFT; // Shorthand for writing Vector3(-1, 0, 0 ). static const glm::vec3 VECTOR3_FORWARD; // Shorthand for writing Vector3( 0, 0, 1 ). static const glm::vec3 VECTOR3_BACKWARD; // Shorthand for writing Vector3( 0, 0, -1 ). static const double PI; }; } #endif
[ "46005019+MANA3DGames@users.noreply.github.com" ]
46005019+MANA3DGames@users.noreply.github.com
bcc27d7c26e7c919a2baebce39e0744be8bdea33
0290bcc4423caa821eb86a189799747e28dc5ec0
/293. Flip Game.cpp
56a5768f3f7cccacfd80feab9ab944710bc60ddd
[]
no_license
lunlun1992/LeetCode
36f783ecd83e482c60506a328277b344aea270a0
72dcd0857431816348573cb9f4337d411b58ac17
refs/heads/master
2021-01-11T20:26:54.724918
2017-08-18T10:43:50
2017-08-18T10:43:50
79,117,277
0
0
null
null
null
null
UTF-8
C++
false
false
439
cpp
class Solution { public: vector<string> generatePossibleNextMoves(string s) { vector<string> ret; int len = s.size(); for(int i = 0; i < len - 1; i++) { if(s[i] == '+' && s[i + 1] == '+') { string now = s; now[i] = '-'; now[i + 1] = '-'; ret.push_back(now); } } return ret; } };
[ "lunlun1992@163.com" ]
lunlun1992@163.com
e085c7000468603f6f318b0e47939e1ea0e56a30
a214a4562dcf5297e5cc6a0f9aac2c4c76ca96a1
/ffs/source/wearleveling/ddi/data_drive/ddi_nand_nssm_get_entry.cpp
427cd17b7c87e2a0b92c4e9ac246d833002b5eb4
[]
no_license
zhouglu/K60F120M
7f5ff41f5d2755a49607f578eda5f684d5886281
fc202886dccb00ad52cbe99406c412163e66f1d4
refs/heads/master
2020-04-23T08:17:56.341993
2013-12-27T08:58:34
2013-12-27T08:58:34
14,609,537
1
0
null
null
null
null
UTF-8
C++
false
false
5,754
cpp
/*HEADER********************************************************************** * * Copyright 2013 Freescale Semiconductor, Inc. * * Freescale Confidential and Proprietary - use of this software is * governed by the Freescale MQX RTOS License distributed with this * material. See the MQX_RTOS_LICENSE file distributed for more * details. * ***************************************************************************** * * THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * ***************************************************************************** * * $FileName: ddi_nand_nssm_get_entry.cpp$ * $Version : 3.8.0.1$ * $Date : Aug-9-2012$ * * Comments: * * This file contains the utilities needed to handle LBA ddi layer functions. * *END************************************************************************/ #include "wl_common.h" #include "ddi/common/ddi_nand_ddi.h" #include "ddi/data_drive/ddi_nand_data_drive.h" #include "ddi_nand_hal.h" #include <string.h> #include "ddi/mapper/mapper.h" #include "buffer_manager/media_buffer.h" using namespace nand; /*FUNCTION*---------------------------------------------------------------- * * Function Name : getMapForVirtualBlock * Returned Value : The map of the requested virtual block number. * If NULL is returned, then an unrecoverable error occurred. * Comments : * Get the appropriate Non-Sequential Sector Map. * This function will return the NonSequential Sector map entry for the given * LBA Block. If the NSSM is not in the table, then build it from the data * in the NAND. * *END*--------------------------------------------------------------------*/ NonsequentialSectorsMap * NssmManager::getMapForVirtualBlock ( /* [IN] Virtual block number to search for. */ uint32_t blockNumber ) { /* Body */ RtStatus_t ret; /* Use the index to search for a matching map. */ NonsequentialSectorsMap * map = static_cast<NonsequentialSectorsMap *>(m_index.find(blockNumber)); if (map) { /* Reinsert the map in LRU order. */ map->removeFromLRU(); map->insertToLRU(); return map; } /* Endif */ /* If it wasn't found, we'll need to build it. */ ret = buildMap(blockNumber, &map); if (ret != SUCCESS) { /* Something bad happened... */ return NULL; } /* Endif */ /* Insert the newly built map into the LRU list. */ map->insertToLRU(); return map; } /* Endbody */ /*FUNCTION*---------------------------------------------------------------- * * Function Name : getEntry * Returned Value : Status of call or error. * Comments : * This function gets the physical sector in the remapped LBA corresponding * to a given linear sector offset. Basically this function returns the * byte array entry of the linear sector offset which is the remapped * sector. * *END*--------------------------------------------------------------------*/ RtStatus_t NonsequentialSectorsMap::getEntry ( /* [IN] Logical sector index */ uint32_t u32LBASectorIdx, /* [OUT] Physical block number */ uint32_t * pu32PhysicalBlockNumber, /* [OUT] Sector offset of the actual sector. */ uint32_t * pu32NS_ActualSectorOffset, /* [OUT] State of the sector */ uint32_t * pu32Occupied ) { /* Body */ uint32_t u32SectorOffset; /* ** The LBA was found above so now using the linear expected LBA sector, ** grab the value in the NonSequential Map Sector. */ u32SectorOffset = m_map[u32LBASectorIdx]; *pu32Occupied = m_map.isOccupied(u32LBASectorIdx); /* See if We have a back-up block. */ if (!(*pu32Occupied) && (m_backupPhysicalBlock != kInvalidAddress)) { /* ** If we have a back-up block, return back-up block's physical block ** number and physical offset into back-up block. */ u32SectorOffset = m_backupMap[u32LBASectorIdx]; *pu32Occupied = m_backupMap.isOccupied(u32LBASectorIdx); *pu32PhysicalBlockNumber = m_backupPhysicalBlock; } /* Endif */ *pu32NS_ActualSectorOffset = u32SectorOffset; return SUCCESS; } /* Endbody */ /*FUNCTION*---------------------------------------------------------------- * * Function Name : insertToLRU * Returned Value : void * Comments : * This function inserts the nonsequentialsectormap object to list * *END*--------------------------------------------------------------------*/ void NonsequentialSectorsMap::insertToLRU() { /* Body */ m_manager->m_lru.insert(this); } /* Endbody */ /*FUNCTION*---------------------------------------------------------------- * * Function Name : removeFromLRU * Returned Value : void * Comments : * This function removes a nonsequentialsectormap object from list * *END*--------------------------------------------------------------------*/ void NonsequentialSectorsMap::removeFromLRU() { /* Body */ m_manager->m_lru.remove(this); } /* Endbody */ /* EOF */
[ "zhouglu@gmail.com" ]
zhouglu@gmail.com
0d24b7ea97bdbf1d12eff34bef11d246bd2d9031
4cb3450b11e46b36a62f53f30a76b7b21deb61da
/CSCI_375/Lab7/Matrix4.cpp
6ab1b92c11f160a4a9c508ab5b6cc4964bceb223
[]
no_license
zrzuch/Various-Projects
b1ba001be04b33196e819faaa5fff025ffab9b72
8cdc8d43ac0a15950ccb013fa6bbf048bb0b2b9f
refs/heads/master
2020-06-23T18:27:10.509606
2019-07-24T22:52:59
2019-07-24T22:52:59
198,714,668
0
0
null
null
null
null
UTF-8
C++
false
false
3,925
cpp
#include <cmath> #include "Math.h" #include "Matrix4.h" // Initialize to identity. Matrix4::Matrix4 () : m_right (1,0,0,0) , m_up (0,1,0,0) , m_back (0,0,1,0) , m_translation(0,0,0,1) { } Matrix4::Matrix4(const Vector4& right, const Vector4& up, const Vector4& back, const Vector4& translation) : m_right(right), m_up(up), m_back(back), m_translation(translation) { } Matrix4::Matrix4(float rx, float ry, float rz, float rw, float ux, float uy, float uz, float uw, float bx, float by, float bz, float bw, float tx, float ty, float tz, float tw) : m_right (rx, ry, rz, rw) , m_up (ux, uy, uz, uw) , m_back (bx, by, bz, bw) , m_translation(tx, ty, tz, tw) { } // Set to identity matrix. void Matrix4::setToIdentity () { m_right = {1,0,0,0}; m_up = {0,1,0,0}; m_back = {0,0,1,0}; m_translation = {0,0,0,1}; } // Set to zero matrix. void Matrix4::setToZero () { m_right.set(0); m_up.set(0); m_back.set(0); m_translation.set(0); } // Return a const pointer to the first element. const float* Matrix4::data () const { return m_right.data(); } glm::mat4 Matrix4::getMat4 () const { return { m_right.x, m_right.y, m_right.z, m_right.w, m_up.x, m_up.y, m_up.z, m_up.w, m_back.x, m_back.y, m_back.z, m_back.w, m_translation.x, m_translation.y, m_translation.z, m_translation.w }; } // For the projection methods, do all computations using // double-s and only cast to float when NECESSARY. // Set this to a perspective projection matrix. void Matrix4::setToPerspectiveProjection (double fovYDegrees, double aspectRatio, double nearPlaneZ, double farPlaneZ) { double tanFOVdiv2 = tan( Math::toRadians(fovYDegrees) / 2); double a00 = 1 / (aspectRatio * tanFOVdiv2); double a11 = 1 / tanFOVdiv2; double a22 = (nearPlaneZ + farPlaneZ) / (nearPlaneZ - farPlaneZ); double a23 = (2 * nearPlaneZ * farPlaneZ) / (nearPlaneZ - farPlaneZ); m_right = {(float)a00, 0, 0, 0 }; m_up = {0, (float)a11, 0, 0 }; m_back = {0, 0, (float)a22, -1}; m_translation = {0, 0, (float)a23, 0 }; } // Set this to a perspective projection matrix using the // 6 clip planes specified as parameters. void Matrix4::setToPerspectiveProjection (double left, double right, double bottom, double top, double nearPlaneZ, double farPlaneZ) { double a00 = 2 * nearPlaneZ / (right - left); double a11 = 2 * nearPlaneZ / (top - bottom); double a02 = (right + left) / (right - left); double a12 = (top + bottom) / (top - bottom); double a22 = (nearPlaneZ + farPlaneZ) / (nearPlaneZ - farPlaneZ); double a23 = (2 * nearPlaneZ * farPlaneZ) / (nearPlaneZ - farPlaneZ); m_right = {(float)a00, 0, 0, 0 }; m_up = {0, (float)a11, 0, 0 }; m_back = {(float)a02, (float)a12, (float)a22, -1}; m_translation = {0, 0, (float)a23, 0 }; } // Set this to an orthographic projection matrix using the // 6 clip planes specified as parameters. void Matrix4::setToOrthographicProjection (double left, double right, double bottom, double top, double nearPlaneZ, double farPlaneZ) { double nearFarDist = nearPlaneZ - farPlaneZ; double a00 = 2/(right-left); double a11 = 2/(top-bottom); double a22 = 2/nearFarDist; double a03 = -(right + left) / (right - left); double a13 = -(top + bottom) / (top - bottom); double a23 = (nearPlaneZ + farPlaneZ) / nearFarDist; m_right = {(float)a00, 0, 0, 0}; m_up = {0, (float)a11, 0, 0}; m_back = {0, 0, (float)a22, 0}; m_translation = {(float)a03, (float)a13, (float)a23, 1}; }
[ "noreply@github.com" ]
noreply@github.com
181773d80579ae8949c1d1c514ac0e1af40b6b66
12e8a2763c0279f60a2bb3de89bb94e4ea68f69b
/Pegasus/inc/DomainListMachines.cpp
cf0992dde2e3d90d205343f21fb9847fd637b232
[]
no_license
s3cj0y/maybe-carbanak-group_ib_smart_boys
618d361d4ddec57eb783c8819b46f9106d4137e7
cf183a258aca3dbd2098c5c818fd97faf688b71d
refs/heads/master
2020-03-22T21:55:10.593309
2018-07-12T14:33:50
2018-07-12T14:33:50
140,721,629
14
14
null
null
null
null
UTF-8
C++
false
false
7,229
cpp
/* DomainListMachines.cpp Enums visible machines in current or any specified domain NB: keep in mind need of local disks scan for *.rdp to get addresses and credentials from there */ #include <windows.h> #include "..\inc\dbg.h" #include "DomainListMachines.h" #ifdef ROUTINES_BY_PTR DomainListMachines_ptrs DomainListMachines_apis; // global var for transparent name translation into call-by-pointer // should be called before any other apis used to fill internal structures VOID DomainListMachines_resolve(DomainListMachines_ptrs *apis) { #ifdef _DEBUG if (IsBadReadPtr(apis, sizeof(DomainListMachines_ptrs))) { DbgPrint("DBG_ERR: bad read ptr %p len %u", apis, sizeof(DomainListMachines_ptrs)); } #endif // save to a global var DomainListMachines_apis = *apis; } #else #include <lm.h> // NetServerEnum() #include <winnetwk.h> // WNetOpenEnum / WNetEnumResource #include "..\inc\mem.h" #include "..\inc\dbg.h" // link essential libs #pragma comment(lib, "netapi32.lib") // NetServerEnum() #pragma comment(lib, "mpr.lib") // WNetOpenEnum / WNetEnumResource /* Fill passed structure with ptrs to all exported functions Used when module compiled as code to provide ptrs to some other child code */ VOID DomainListMachines_imports(DomainListMachines_ptrs *apis) { apis->fndlmEnumV1 = dlmEnumV1; apis->fndlmEnumV2 = dlmEnumV2; } // performs enum using Browser service (NetServerEnum) // wszDomain should be NULL for current domain BOOL dlmEnumV1(LPWSTR wszDomain) { BOOL bRes = FALSE; // func result NET_API_STATUS nStatus; // NetServerEnum() result LPSERVER_INFO_101 pBuf = NULL; LPSERVER_INFO_101 pTmpBuf; DWORD dwEntriesRead = 0; DWORD dwTotalEntries = 0; DWORD i; DbgPrint("entered"); // query netapi nStatus = NetServerEnum(NULL, 101, (LPBYTE *)&pBuf, MAX_PREFERRED_LENGTH, &dwEntriesRead, &dwTotalEntries, SV_TYPE_ALL, wszDomain, NULL); // check for error if ((nStatus != NERR_Success) && (nStatus != ERROR_MORE_DATA)) { DbgPrint("ERR: NetServerEnum() unexpected status %04Xh", nStatus); return bRes; } if (!(pTmpBuf = pBuf)) { DbgPrint("ERR: received NULL ptr"); return bRes; } // do enum for (i = 0; i < dwEntriesRead; i++) { if (!pTmpBuf) { DbgPrint("ERR: got NULL ptr"); break; } DbgPrint("[%01u] name[%ws] ver%d.%d platform %d type %08Xh", i + 1, pTmpBuf->sv101_name, pTmpBuf->sv101_version_major, pTmpBuf->sv101_version_minor, pTmpBuf->sv101_platform_id, pTmpBuf->sv101_type); pTmpBuf++; } // for i // free buffer allocated by called func if (pBuf != NULL) { NetApiBufferFree(pBuf); } return bRes; } // receives and parses each item of NETRESOURCE structure BOOL _dlmWnetParseStructure(int iPos, LPNETRESOURCE lpnrLocal, LPWSTR wszCurrentDomain, WNETENUMITEMSFUNC efnEnumFunc, LPVOID pCallbackParam) { /* DbgPrint("[%ws] i=%d dwType=%u dwDisplayType=%u dwUsage=%04Xh lpLocalName=[%ws] lpRemoteName=[%ws] lpComment=[%ws]", wszCurrentDomain, iPos, lpnrLocal->dwType, lpnrLocal->dwDisplayType, lpnrLocal->dwUsage, lpnrLocal->lpLocalName, lpnrLocal->lpRemoteName, lpnrLocal->lpComment); */ // lpnrLocal->dwDisplayType are RESOURCEDISPLAYTYPE_* from WinNetWk.h // on each item, pass it to enum function, if defined if (efnEnumFunc) { return efnEnumFunc(lpnrLocal, wszCurrentDomain, pCallbackParam); } else { return TRUE; } } // recursive enum function for WNetOpenEnum / WNetEnumResource // wszCurrentDomain is used internall to pass by ptr to current domain while enumerating it's items // bEnumAllNetworks controls if need to enum all machines in all available networks BOOL WINAPI _dlmWnetEnumFunc(LPNETRESOURCE lpnr, BOOL bEnumShares, LPWSTR wszCurrentDomain, BOOL bEnumAllNetworks, WNETENUMITEMSFUNC efnEnumFunc, LPVOID pCallbackParam) { BOOL bRes = FALSE; // function result DWORD dwResult, dwResultEnum; // api call results HANDLE hEnum = NULL; // for WNetOpenEnum DWORD cbBuffer = 16384 * 4; // 16K is a good size DWORD cEntries = -1; // enumerate all possible entries LPNETRESOURCE lpnrLocal = NULL; // pointer to enumerated structures DWORD i; LPWSTR wszDomainLocal = wszCurrentDomain; DWORD dwScope = RESOURCE_CONTEXT; // by default, enum local group if (bEnumAllNetworks) { dwScope = RESOURCE_GLOBALNET; } dwResult = WNetOpenEnum(dwScope, // selected network resources RESOURCETYPE_ANY, // all resources 0, // enumerate all resources lpnr, // NULL first time the function is called &hEnum); // handle to the resource if (dwResult != NO_ERROR) { /* DbgPrint("ERR: WNetOpenEnum() le %04Xh", GetLastError()); */ return bRes; } // alloc resulting array buffer lpnrLocal = (LPNETRESOURCE)my_alloc(cbBuffer); do { // wipe buffer on every iteration memset(lpnrLocal, 0, cbBuffer); dwResultEnum = WNetEnumResource(hEnum, // resource handle &cEntries, // defined locally as -1 lpnrLocal, // LPNETRESOURCE &cbBuffer); // buffer size // check for ok result if (dwResultEnum != NO_ERROR) { // if a real error occured, like ERROR_ACCESS_DENIED (5) on enumerating shares on different domain / from non-authorized account if (dwResultEnum != ERROR_NO_MORE_ITEMS) { DbgPrint("ERR: WNetEnumResource() le %04Xh", GetLastError()); break; } break; } // ! NO_ERROR result // ok result if got here, proceed with item parse for (i = 0; i < cEntries; i++) { // if got new domain - save for next calls if (lpnrLocal[i].dwDisplayType == RESOURCEDISPLAYTYPE_DOMAIN) { wszDomainLocal = lpnrLocal[i].lpRemoteName; } // invoke callback and check if it allows to parse further if (!_dlmWnetParseStructure(i, &lpnrLocal[i], wszDomainLocal, efnEnumFunc, pCallbackParam)){ DbgPrint("callback asked to stop enum, exiting"); // set like all items are ended dwResultEnum = ERROR_NO_MORE_ITEMS; break; // from for i } // check for RESOURCEUSAGE_CONTAINER flag set -> need to go deeper if (RESOURCEUSAGE_CONTAINER == (lpnrLocal[i].dwUsage & RESOURCEUSAGE_CONTAINER)) { // check if allowed to parse shares if (lpnrLocal[i].dwDisplayType == RESOURCEDISPLAYTYPE_SERVER) { if (bEnumShares) { _dlmWnetEnumFunc(&lpnrLocal[i], bEnumShares, wszDomainLocal, bEnumAllNetworks, efnEnumFunc, pCallbackParam); } //else { DbgPrint("forbidden to enum shares"); } } else { // this to prevent looping on enumerating only local network if ((bEnumAllNetworks) || ((!bEnumAllNetworks) && (i > 0))) { _dlmWnetEnumFunc(&lpnrLocal[i], bEnumShares, wszDomainLocal, bEnumAllNetworks, efnEnumFunc, pCallbackParam); } } } // RESOURCEUSAGE_CONTAINER check } // for } while (dwResultEnum != ERROR_NO_MORE_ITEMS); // check for ok finish if (dwResultEnum == ERROR_NO_MORE_ITEMS) { bRes = TRUE; } // free used resources my_free(lpnrLocal); WNetCloseEnum(hEnum); //DbgPrint("all done"); return bRes; } // performs enum using WNetOpenEnum / WNetEnumResource BOOL dlmEnumV2(BOOL bEnumShares, BOOL bEnumAllNetworks, WNETENUMITEMSFUNC efnEnumFunc, LPVOID pCallbackParam) { //BOOL bRes = FALSE; return _dlmWnetEnumFunc(NULL, bEnumShares, NULL, bEnumAllNetworks, efnEnumFunc, pCallbackParam); //return bRes; } #endif
[ "ic3sk9@gmail.com" ]
ic3sk9@gmail.com
01405f977919e83d2d75fa28510fd01a83f5d418
72aa7fd11d2f0d8a3667a25a169abc58f69af71e
/HANGMAN/Funtions/RandomizeWord/main.cpp
2e72e632c497f5c4d24497f2d35de6b4e1b40c34
[]
no_license
AldCls3322/HANGMAN_game
b62937bdac972eb9b8e040735d3dfb2dad58285c
aedb058af6ae823dd0670e860c089dd5c8f43ee6
refs/heads/master
2022-12-17T17:55:06.487184
2020-09-23T02:53:51
2020-09-23T02:53:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,852
cpp
#include <iostream> #include <fstream> using namespace std; int Random() { int num; int con=-1; char c; ifstream file; file.open("HangManWords.txt"); while (!file.eof()) { c=file.get(); if (c=='.') { con++; } } cout << "Write a random/non-decimal number, from 0 - " << con << endl; cin >> num; return num; } int BrowseWrd(int n) { int tam=-1; char punto; int con=0; char c; ifstream file; file.open("HangManWords.txt"); c=file.get(); while (!file.eof()) { punto=file.get(); cout << punto << endl; if (punto=='.') { con++; } else if (con==n) { while (c!='.') { c=file.get(); cout << c; tam++; } } } file.close(); return tam; } void OutputWord(char palab[],int tam, int n) { char punto; int con=0; int can=-1; char c; ifstream file; file.open("HangManWords.txt"); c=file.get(); while (!file.eof()) { punto=file.get(); if (punto=='.') { con++; } else if (con==n) { ofstream archpal; archpal.open("HangManWord.txt"); while (c!='.') { c=file.get(); can++; palab[can]=c; cout << palab[can]; } archpal << palab; archpal.close(); } } file.close(); } int main() { int randomn; int tam; randomn=Random(); tam=BrowseWrd(randomn); char palab[tam]; OutputWord(palab,tam,randomn); return 0; }
[ "noreply@github.com" ]
noreply@github.com
46f52ef1ce2a0ee3c7f2e1d50ebc7d36474199f4
ce8bd73a9cda2d65d0610f2442847bf4ee647da5
/ext/stub/java/lang/ClassCastException-stub.cpp
7914c70a629cce744deefd9942db6f930083ffb6
[]
no_license
cprice404/j2c-ts-config
5fec505bd0a9d3b7c968e5d60e7f66db323d9cc4
4fe6cc64c7035b92251ef645cace6898344551de
refs/heads/master
2020-12-24T13:29:05.975373
2015-07-08T06:00:04
2015-07-08T06:00:04
38,735,023
0
0
null
null
null
null
UTF-8
C++
false
false
1,309
cpp
// Generated from /home/cprice/software/java/jdk1.8.0_45/jre/lib/rt.jar #include <java/lang/ClassCastException.hpp> extern void unimplemented_(const char16_t* name); java::lang::ClassCastException::ClassCastException(const ::default_init_tag&) : super(*static_cast< ::default_init_tag* >(0)) { clinit(); } java::lang::ClassCastException::ClassCastException() : ClassCastException(*static_cast< ::default_init_tag* >(0)) { ctor(); } java::lang::ClassCastException::ClassCastException(String* s) : ClassCastException(*static_cast< ::default_init_tag* >(0)) { ctor(s); } constexpr int64_t java::lang::ClassCastException::serialVersionUID; void ::java::lang::ClassCastException::ctor() { /* stub */ /* super::ctor(); */ unimplemented_(u"void ::java::lang::ClassCastException::ctor()"); } void ::java::lang::ClassCastException::ctor(String* s) { /* stub */ /* super::ctor(); */ unimplemented_(u"void ::java::lang::ClassCastException::ctor(String* s)"); } extern java::lang::Class* class_(const char16_t* c, int n); java::lang::Class* java::lang::ClassCastException::class_() { static ::java::lang::Class* c = ::class_(u"java.lang.ClassCastException", 28); return c; } java::lang::Class* java::lang::ClassCastException::getClass0() { return class_(); }
[ "chris@puppetlabs.com" ]
chris@puppetlabs.com
5add837fb123e5b35f9e5518287a8242ec043f4a
b20761ef074a58d88ab178c54dde7117fd5a7ea4
/LedNumber.cpp
b84e8c5467b5536664bf3d97d74c82852a303809
[]
no_license
Cyelliott/lab3-source_code
f2c6eba18f60033e1f63632cad25bc9527bd3f45
f525e21d235ca52f7cb8af035ad49ca744a8a87c
refs/heads/master
2020-12-29T09:18:48.230700
2020-02-06T22:02:53
2020-02-06T22:02:53
238,552,623
0
1
null
null
null
null
UTF-8
C++
false
false
7,762
cpp
#include <iostream> #include <cstdio> #include <cstdlib> #include <fcntl.h> #include <unistd.h> #include <sys/mman.h> using namespace std; void Write1Led(char *pBase, int ledNum, int state); int Read1Switch(char *pBase, int switchNum); int ReadAllSwitches(char *pBase); void WriteAllLeds(char *pBase, int value); // Physical base address of GPIO const unsigned gpio_address = 0x400d0000; // Length of memory-mapped IO window const unsigned gpio_size = 0xfff; const int gpio_led1_offset = 0x12C; // Offset for LED1 const int gpio_led2_offset = 0x130; // Offset for LED2 const int gpio_led3_offset = 0x134; // Offset for LED3 const int gpio_led4_offset = 0x138; // Offset for LED4 const int gpio_led5_offset = 0x13C; // Offset for LED5 const int gpio_led6_offset = 0x140; // Offset for LED6 const int gpio_led7_offset = 0x144; // Offset for LED7 const int gpio_led8_offset = 0x148; // Offset for LED8 const int gpio_sw1_offset = 0x14C; // Offset for Switch 1 const int gpio_sw2_offset = 0x150; // Offset for Switch 2 const int gpio_sw3_offset = 0x154; // Offset for Switch 3 const int gpio_sw4_offset = 0x158; // Offset for Switch 4 const int gpio_sw5_offset = 0x15C; // Offset for Switch 5 const int gpio_sw6_offset = 0x160; // Offset for Switch 6 const int gpio_sw7_offset = 0x164; // Offset for Switch 7 const int gpio_sw8_offset = 0x168; // Offset for Switch 8 const int gpio_pbtnl_offset = 0x16C; // Offset for left push button const int gpio_pbtnr_offset = 0x170; // Offset for right push button const int gpio_pbtnu_offset = 0x174; // Offset for up push button const int gpio_pbtnd_offset = 0x178; // Offset for down push button const int gpio_pbtnc_offset = 0x17C; // Offset for center push button /** * Write a 4-byte value at the specified general-purpose I/O location. * * @param pBase Base address returned by 'mmap'. * @parem offset Offset where device is mapped. * @param value Value to be written. */ void RegisterWrite(char *pBase, int offset, int value) { * (int *) (pBase + offset) = value; } /** * Read a 4-byte value from the specified general-purpose I/O location. * * @param pBase Base address returned by 'mmap'. * @param offset Offset where device is mapped. * @return Value read. */ int RegisterRead(char *pBase, int offset) { return * (int *) (pBase + offset); } /** * Initialize general-purpose I/O * - Opens access to physical memory /dev/mem * - Maps memory at offset 'gpio_address' into virtual address space * * @param fd File descriptor passed by reference, where the result * of function 'open' will be stored. * @return Address to virtual memory which is mapped to physical, * or MAP_FAILED on error. */ char *Initialize(int *fd) { *fd = open( "/dev/mem", O_RDWR); return (char *) mmap(NULL, gpio_size, PROT_READ | PROT_WRITE, MAP_SHARED, *fd, gpio_address); } /** * Close general-purpose I/O. * * @param pBase Virtual address where I/O was mapped. * @param fd File descriptor previously returned by 'open'. */ void Finalize(char *pBase, int fd) { munmap(pBase, gpio_size); close(fd); } int main() { // Initialize int fd, switchRead; char *pBase = Initialize(&fd); // Check error if (pBase == MAP_FAILED) { perror("Mapping I/O memory failed - Did you run with 'sudo'?\n"); return -1; } // ************** Put your code here ********************** bool active = true; bool repeat; char choice; while (active) { repeat = true; int inputLED, LEDState, inputSwitch, outputSwitch; cout << "Please input an LED number to turn on/off: "; cin >> inputLED; cout << endl; cout << "Please input the desired state of that LED (0 or 1): "; cin >> LEDState; cout << endl; cout << "Please input a switch number to read: "; cin >> inputSwitch; cout << endl; Write1Led(pBase, inputLED, LEDState); outputSwitch = Read1Switch(pBase, inputSwitch); if (outputSwitch == 1) cout << "Switch #" << inputSwitch << " is on." << endl; else cout << "Switch #" << inputSwitch << " is off." << endl << endl; cout << "Would you like to change an LED or check a switch again? (y/n): "; while (repeat) { cin >> choice; switch (choice) { case 'y' : { cout << endl << endl; repeat = false; } break; case 'n' : { cout << endl << "Moving onto binary reader & printer.." << endl; repeat = false; active = false; } break; default : { cout << "ERROR: Please input a valid option: "; } break; } } } active = true; repeat = true; while (active) { repeat = true; switchRead = ReadAllSwitches(pBase); WriteAllLeds(pBase, switchRead); cout << switchRead << endl; cout << "Would you like to read the binary value to the LEDs again? (y/n): "; while (repeat) { cin >> choice; switch (choice) { case 'y' : { cout << endl << endl; repeat = false; } break; case 'n' : { cout << endl << "Closing program.." << endl; repeat = false; active = false; } break; default : { cout << "ERROR: Please input a valid option: "; } break; } } } // Done Finalize(pBase, fd); return 0; } void Write1Led(char *pBase, int ledNum, int state) { int offset = 0x12C; for (int x = 0; x < ledNum; x++) offset = offset + 0x004; RegisterWrite(pBase, offset, state); } int Read1Switch(char *pBase, int switchNum) { int offset = 0x14C; for (int x = 0; x < switchNum; x++) offset = offset + 0x004; return RegisterRead(pBase, offset); } int ReadAllSwitches(char *pBase) { int switch_val = 0; switch_val = switch_val + Read1Switch(pBase, 0); switch_val = switch_val + 2*Read1Switch(pBase, 1); switch_val = switch_val + 4*Read1Switch(pBase, 2); switch_val = switch_val + 8*Read1Switch(pBase, 3); switch_val = switch_val + 16*Read1Switch(pBase, 4); switch_val = switch_val + 32*Read1Switch(pBase, 5); switch_val = switch_val + 64*Read1Switch(pBase, 6); switch_val = switch_val + 128 *Read1Switch(pBase, 7); return switch_val; } void WriteAllLeds(char *pBase, int value) { int bit_val = 0; Write1Led(pBase, 0,value%2); Write1Led(pBase, 1,(value/2)%2); Write1Led(pBase, 2, (value/4)%2); Write1Led(pBase, 3, (value/8)%2); Write1Led(pBase, 4, (value/16)%2); Write1Led(pBase, 5, (value/32)%2); Write1Led(pBase, 6, (value/64)%2); Write1Led(pBase, 7, (value/128)%2); }
[ "noreply@github.com" ]
noreply@github.com
dd1fdf0074253169f1d1001d9dab885c56097964
a26aa08a21c299f0a5725b0c46f0321a88d2593d
/GRender/GRender/Render/Core/Image.h
f724b4cb07932f71c9302c268d2e5c39548a6d75
[]
no_license
GavinZL/GRender
387c856ffa20cfd076111385740284574b8bbfa3
46b84801e867c446e3b8b6b7be235bc6d2f82380
refs/heads/master
2021-08-29T23:30:49.341942
2017-12-15T08:51:50
2017-12-15T08:51:50
113,120,953
0
0
null
null
null
null
UTF-8
C++
false
false
8,150
h
/**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_IMAGE_H__ #define __CC_IMAGE_H__ #include "../Comm/Macors.h" #include "Texture2D.h" #include "Ref.h" // premultiply alpha, or the effect will wrong when want to use other pixel format in Texture2D, // such as RGB888, RGB5A1 #define CC_RGB_PREMULTIPLY_ALPHA(vr, vg, vb, va) \ (unsigned)(((unsigned)((unsigned char)(vr) * ((unsigned char)(va) + 1)) >> 8) | \ ((unsigned)((unsigned char)(vg) * ((unsigned char)(va) + 1) >> 8) << 8) | \ ((unsigned)((unsigned char)(vb) * ((unsigned char)(va) + 1) >> 8) << 16) | \ ((unsigned)(unsigned char)(va) << 24)) NAMESPACE_BEGIN /** * @addtogroup platform * @{ */ /** @brief Structure which can tell where mipmap begins and how long is it */ typedef struct _MipmapInfo { unsigned char* address; int len; _MipmapInfo():address(NULL),len(0){} }MipmapInfo; class Image : public Ref { public: friend class TextureCache; /** * @js ctor */ Image(); /** * @js NA * @lua NA */ virtual ~Image(); /** Supported formats for Image */ enum class Format { //! JPEG JPG, //! PNG PNG, //! TIFF TIFF, //! WebP WEBP, //! PVR PVR, //! ETC ETC, //! S3TC S3TC, //! ATITC ATITC, //! TGA TGA, //! Raw Data RAW_DATA, //! Unknown format UNKOWN }; /** @brief Load the image from the specified path. @param path the absolute file path. @return true if loaded correctly. */ bool initWithImageFile(const std::string& path); /** @brief Load image from stream buffer. @param data stream buffer which holds the image data. @param dataLen data length expressed in (number of) bytes. @return true if loaded correctly. * @js NA * @lua NA */ bool initWithImageData(const unsigned char * data, ssize_t dataLen); // @warning kFmtRawData only support RGBA8888 bool initWithRawData(const unsigned char * data, ssize_t dataLen, int width, int height, int bitsPerComponent, bool preMulti = false); // Getters inline unsigned char * getData() { return _data; } inline ssize_t getDataLen() { return _dataLen; } inline Format getFileType() {return _fileType; } inline Texture2D::PixelFormat getRenderFormat() { return _renderFormat; } inline int getWidth() { return _width; } inline int getHeight() { return _height; } inline int getNumberOfMipmaps() { return _numberOfMipmaps; } inline MipmapInfo* getMipmaps() { return _mipmaps; } inline bool hasPremultipliedAlpha() { return _hasPremultipliedAlpha; } //CC_DEPRECATED_ATTRIBUTE inline bool isPremultipliedAlpha() { return _hasPremultipliedAlpha; } int getBitPerPixel(); bool hasAlpha(); bool isCompressed(); /** @brief Save Image data to the specified file, with specified format. @param filePath the file's absolute path, including file suffix. @param isToRGB whether the image is saved as RGB format. */ bool saveToFile(const std::string &filename, bool isToRGB = true); /** treats (or not) PVR files as if they have alpha premultiplied. Since it is impossible to know at runtime if the PVR images have the alpha channel premultiplied, it is possible load them as if they have (or not) the alpha channel premultiplied. By default it is disabled. */ static void setPVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied); //add by zwx use to decode imagedata bool ImageDataDecode(unsigned char *pData, unsigned int &uSize); bool DecryptionOld( unsigned char* pData, unsigned int &uSize); bool DecryptionNew( unsigned char* pData, unsigned int &uSize); protected: bool initWithJpgData(const unsigned char * data, ssize_t dataLen); bool initWithPngData(const unsigned char * data, ssize_t dataLen); bool initWithTiffData(const unsigned char * data, ssize_t dataLen); bool initWithWebpData(const unsigned char * data, ssize_t dataLen); bool initWithPVRData(const unsigned char * data, ssize_t dataLen); bool initWithPVRv2Data(const unsigned char * data, ssize_t dataLen); bool initWithPVRv3Data(const unsigned char * data, ssize_t dataLen); bool initWithETCData(const unsigned char * data, ssize_t dataLen); bool initWithS3TCData(const unsigned char * data, ssize_t dataLen); bool initWithATITCData(const unsigned char *data, ssize_t dataLen); typedef struct sImageTGA tImageTGA; bool initWithTGAData(tImageTGA* tgaData); bool saveImageToPNG(const std::string& filePath, bool isToRGB = true); bool saveImageToJPG(const std::string& filePath); void premultipliedAlpha(); protected: /** @brief Determine how many mipmaps can we have. Its same as define but it respects namespaces */ static const int MIPMAP_MAX = 16; unsigned char *_data; ssize_t _dataLen; int _width; int _height; bool _unpack; Format _fileType; Texture2D::PixelFormat _renderFormat; MipmapInfo _mipmaps[MIPMAP_MAX]; // pointer to mipmap images int _numberOfMipmaps; // false if we cann't auto detect the image is premultiplied or not. bool _hasPremultipliedAlpha; std::string _filePath; protected: // noncopyable Image(const Image& rImg); Image & operator=(const Image&); /* @brief The same result as with initWithImageFile, but thread safe. It is caused by loadImage() in TextureCache.cpp. @param fullpath full path of the file. @param imageType the type of image, currently only supporting two types. @return true if loaded correctly. */ bool initWithImageFileThreadSafe(const std::string& fullpath); Format detectFormat(const unsigned char * data, ssize_t dataLen); bool isPng(const unsigned char * data, ssize_t dataLen); bool isJpg(const unsigned char * data, ssize_t dataLen); bool isTiff(const unsigned char * data, ssize_t dataLen); bool isWebp(const unsigned char * data, ssize_t dataLen); bool isPvr(const unsigned char * data, ssize_t dataLen); bool isEtc(const unsigned char * data, ssize_t dataLen); bool isS3TC(const unsigned char * data,ssize_t dataLen); bool isATITC(const unsigned char *data, ssize_t dataLen); // ##add read rb file unsigned char* readDataFromFile(const std::string& file, unsigned int& len); }; // end of platform group /// @} NAMESPACE_END #endif // __CC_IMAGE_H__
[ "junee1122@163.com" ]
junee1122@163.com
04fb22c56be4baafc89c6b7f198298c163df49c3
e2aa5b125a9c36a81536fdd390dccb68830f120e
/project/midterm/3. check/main.cpp
c30a732f5c3505684596c75cf070967091cfc9e2
[]
no_license
cw2744101/winter-cis-5-course-40626
98e5667f6aac5552a8e2a0b46909c17a7550aac9
75e7b8d2f072ceaee08b822b348066614851abd0
refs/heads/master
2021-05-04T17:09:48.605484
2018-02-12T07:26:47
2018-02-12T07:26:47
120,265,410
0
0
null
null
null
null
UTF-8
C++
false
false
2,877
cpp
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /* * File: main.cpp * Author: chenl * * Created on 2018年1月27日, 下午7:36 */ #include <iostream> using namespace std; /* * */ int main(int argc, char** argv) { //Declare Variables unsigned short num; unsigned char n1000s,n100s,n10s,n1s; //Initialize Variables cout<<"Input an integer [1-3000] convert to an English Check value."<<endl; cin>>num; //Process/Map inputs to outputs n1000s=(num-num%1000)/1000; num%=1000; n100s=(num-num%100)/100; num%=100; n10s=(num-num%10)/10; num%=10; n1s=num; if(num>0 && num<3001) { //Display the 1000's place switch(n1000s){ case 3:cout<<"Three Thousand ";break; case 2:cout<<"Two Thousand ";break; case 1:cout<<"One Thousand ";break; } //Display the 100's place switch(n100s){ case 9:cout<<"Nine Hundred " ;break; case 8:cout<<"Eight Hundred ";break; case 7:cout<<"Seven Hundred ";break; case 6:cout<<"Six Hundred ";break; case 5:cout<<"Five Hundred ";break; case 4:cout<<"Four Hundred ";break; case 3:cout<<"Three Hundred ";break; case 2:cout<<"Two Hundred ";break; case 1:cout<<"One Hundred ";break; } //Display the 100's place if(n10s!=1){ switch(n10s){ case 9:cout<<"Ninety ";break; case 8:cout<<"Eighty ";break; case 7:cout<<"Seventy ";break; case 6:cout<<"Sixty ";break; case 5:cout<<"Fifty ";break; case 4:cout<<"Fourty ";break; case 3:cout<<"Thirty ";break; case 2:cout<<"Twenty ";break; case 1:cout<<"Ten ";break; } //Display the 1's place switch(n1s){ case 9:cout<<"Nine";break; case 8:cout<<"Eight";break; case 7:cout<<"Seven";break; case 6:cout<<"Six";break; case 5:cout<<"Five";break; case 4:cout<<"Four";break; case 3:cout<<"Three";break; case 2:cout<<"Two";break; case 1:cout<<"One";break; } } else if(n10s=1&&n1s!=0) { switch(n1s){ case 9:cout<<"Nineteen";break; case 8:cout<<"Eighteen";break; case 7:cout<<"Seventeen";break; case 6:cout<<"Sixteen";break; case 5:cout<<"Fifteen";break; case 4:cout<<"fourteen";break; case 3:cout<<"Thirteen";break; case 2:cout<<"Twelve";break; case 1:cout<<"Eleven";break; } } } //Output the check value cout<<" and no/100's Dollars"<<endl; //Exit return 0; }
[ "chenlinwcl@gmail.com" ]
chenlinwcl@gmail.com
aeac4b4236163783630d9b39c06ee457a5665a5f
2e5c7683142042f86e0380a3cac0ef5adcb61d3d
/source/ev3way2/unit/device/GyroDriver.cpp
dfca746b26b7b2d12eee62d98831772ab414b37c
[]
no_license
kuromido/ET_RoboCon_2017
15d975d54ce60fdbff0a62fbc18b2190200df727
cd154bec4b448d4242a29aade1e6a659d5c61428
refs/heads/master
2019-08-05T01:36:21.784159
2017-09-19T13:29:28
2017-09-19T13:29:28
83,324,557
0
0
null
2017-02-27T15:18:47
2017-02-27T15:18:47
null
UTF-8
C++
false
false
657
cpp
#include "GyroDriver.h" namespace unit { const int GYRO_OFFSET = 0; GyroDriver::GyroDriver() { mGyroOffset = GYRO_OFFSET; mGyroSensor = nullptr; } GyroDriver::GyroDriver(const ePortS port) { mGyroOffset = GYRO_OFFSET; mGyroSensor = new ev3api::GyroSensor(port); } GyroDriver::~GyroDriver() { if(mGyroSensor != nullptr) delete mGyroSensor; } void GyroDriver::Reset() { mGyroSensor->reset(); } int GyroDriver::GetAnglerVelocity() { return mGyroSensor->getAnglerVelocity(); } int GyroDriver::GetAngle() { return mGyroSensor->getAngle(); } int GyroDriver::getOffset() { return mGyroOffset; } } // namespace unit
[ "kuromido@users.noreply.github.com" ]
kuromido@users.noreply.github.com
31335186459b0cd3abbc497fbce3825fe91d90dd
04a540847c1333c987a1957fd8d31197c594f6bb
/SWEA/3431.cpp
66358fb7cd8d8452310656f0cefc84c1f35bce50
[]
no_license
k8440009/Algorithm
fd148269b264b580876c7426e19dbe2425ddc1ab
a48eba0ac5c9f2e10f3c509ce9d349c8a1dc3f0c
refs/heads/master
2023-04-02T16:06:10.260768
2023-04-02T11:04:32
2023-04-02T11:04:32
200,506,643
0
0
null
null
null
null
UTF-8
C++
false
false
549
cpp
// 3431. 준환이의 운동관리 #include <iostream> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int tc; cin >> tc; for (int i = 1; i <= tc; i++) { int l, u, x; cin >> l >> u >> x; cout << "#" << i << ' '; // 필요한 운동량 보다 많은 운동 if (x > u) cout << -1 << '\n'; else if (x < l) cout << l - x << '\n'; else if (x > l && x < u) cout << 0 << '\n'; } return 0; }
[ "lucas0730@naver.com" ]
lucas0730@naver.com
3d6205cb688f86c7871a9fe9ca8fc971d26d6aa2
ace546fbf1dcb410f07c07b36e2f3e6330c9fe26
/Practice/div1_plus_div2_505/Q2.cpp
1a39f1b1721c6822d54850190dc99cb1183edb88
[]
no_license
rahulsingh24/datastructures
a0b7497e1efede1490580bf6d027ad59453b3a03
a8a0b5181b9eb86e4fb23a2a2f6a68be789b62bf
refs/heads/master
2020-04-02T07:34:38.929558
2018-10-22T20:12:20
2018-10-22T20:12:20
154,203,752
0
1
null
2018-10-22T20:12:21
2018-10-22T19:29:44
C++
UTF-8
C++
false
false
2,847
cpp
#include <bits/stdc++.h> #include <algorithm> #include <math.h> #include <list> #include <map> #include <utility> #include <vector> #include <set> #include <string> #include <queue> using namespace std; #define ll long long int #define INF 1000000007 #define INFLL 1000000000000000011LL #define pb(x) push_back(x) #define mp make_pair #define fi first #define se second #define vi vector #define gtl(x) getline(cin, (x)) #define all(a) (a).begin(), (a).end() #define sz(a) (int)((a).size()) #define setv(x,a) memset(x,a,sizeof(x)) #define ull unsigned long long int long long modmult(long long a,long long b,long long mod) { if (a == 0 || b < mod / a) return (a*b)%mod; long long sum; sum = 0; while(b>0) { if(b&1) sum = (sum + a) % mod; a = (2*a) % mod; b>>=1; } return sum; } ull PowMod(ull n, ll m) { ull ret = 1; ull a = m; while (n > 0) { if (n & 1) ret = ((ret%INF) * (a%INF)) % INF; a = ((a%INF) * (a%INF)) % INF; n >>= 1; } return ret; } int gcd(int a, int b) { if (a == 0) return b; if (b == 0) return a; if (a < 0) return gcd(-1 * a, b); if (b < 0) return gcd(a, -1 * b); if (a > b) return gcd(b, a); return gcd(b%a, a); } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin>>n; pair<ll,ll> p[n]; ll x,y; for(int i=0;i<n;i++) { cin>>x>>y; p[i].first = x; p[i].second = y; } sort(p,p+n); vector<ll> v; y = p[0].first; // int prim=1; for(ll i=2;i*i<=y;i++) { if(y%i==0) { // prim=0; v.pb(i); while(y%i==0) { y = y/i; } } } if(y>1) v.pb(y); y = p[0].second; // prim=1; for(int i=2;i*i<=y;i++) { if(y%i==0) { // prim=0; v.pb(i); while(y%i==0) { y = y/i; } } } if(y>1) v.pb(y); sort(v.begin(),v.end()); vector<ll>::iterator it; it = unique (v.begin(), v.end()); v.resize(distance(v.begin(),it) ); // for(int i=0;i<v.size();i++) { // cout<<v[i]<<" "; // } // cout<<endl; int i=0; int check; /* for(;i<v.size();i++) { if(v[i]!=1) break; }*/ for(;i<v.size();i++) { check=0; for(int j=0;j<n;j++) { if(p[j].first%v[i]!=0 && p[j].second%v[i]!=0) { // cout<<"dhanraj"<<endl; check=1; break; } } // cout<<"i = "<<i<<endl; if(check==0) { break; } } // cout<<"i2 = "<<i<<endl; if(i<v.size()) cout<<v[i]<<endl; else cout<<-1<<endl; }
[ "sahudhanraj123@gmail.com" ]
sahudhanraj123@gmail.com
5678ddfd068793da1ee2f7ae418e4497440891de
ac8e27210d8ae1c79e7d0d9db1bcf4e31c737718
/tools/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
e85ca3b7a9250e5346b16e246316ecc6ffd5b4bd
[ "NCSA", "Apache-2.0", "LLVM-exception" ]
permissive
steleman/flang9
d583d619bfb67d27a995274e30c8c1a642696ec1
4ad7c213b30422e1e0fcb3ac826640d576977d04
refs/heads/master
2020-11-27T09:50:18.644313
2020-03-07T14:37:32
2020-03-07T14:37:32
229,387,867
0
0
Apache-2.0
2019-12-21T06:35:35
2019-12-21T06:35:34
null
UTF-8
C++
false
false
3,967
h
//===-- NativeProcessNetBSD.h --------------------------------- -*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef liblldb_NativeProcessNetBSD_H_ #define liblldb_NativeProcessNetBSD_H_ #include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/FileSpec.h" #include "NativeThreadNetBSD.h" #include "lldb/Host/common/NativeProcessProtocol.h" namespace lldb_private { namespace process_netbsd { /// \class NativeProcessNetBSD /// Manages communication with the inferior (debugee) process. /// /// Upon construction, this class prepares and launches an inferior process /// for debugging. /// /// Changes in the inferior process state are broadcasted. class NativeProcessNetBSD : public NativeProcessProtocol { public: class Factory : public NativeProcessProtocol::Factory { public: llvm::Expected<std::unique_ptr<NativeProcessProtocol>> Launch(ProcessLaunchInfo &launch_info, NativeDelegate &native_delegate, MainLoop &mainloop) const override; llvm::Expected<std::unique_ptr<NativeProcessProtocol>> Attach(lldb::pid_t pid, NativeDelegate &native_delegate, MainLoop &mainloop) const override; }; // NativeProcessProtocol Interface Status Resume(const ResumeActionList &resume_actions) override; Status Halt() override; Status Detach() override; Status Signal(int signo) override; Status Kill() override; Status GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info) override; Status ReadMemory(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read) override; Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size, size_t &bytes_written) override; Status AllocateMemory(size_t size, uint32_t permissions, lldb::addr_t &addr) override; Status DeallocateMemory(lldb::addr_t addr) override; lldb::addr_t GetSharedLibraryInfoAddress() override; size_t UpdateThreads() override; const ArchSpec &GetArchitecture() const override { return m_arch; } Status SetBreakpoint(lldb::addr_t addr, uint32_t size, bool hardware) override; Status GetLoadedModuleFileSpec(const char *module_path, FileSpec &file_spec) override; Status GetFileLoadAddress(const llvm::StringRef &file_name, lldb::addr_t &load_addr) override; llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> GetAuxvData() const override; // Interface used by NativeRegisterContext-derived classes. static Status PtraceWrapper(int req, lldb::pid_t pid, void *addr = nullptr, int data = 0, int *result = nullptr); private: MainLoop::SignalHandleUP m_sigchld_handle; ArchSpec m_arch; LazyBool m_supports_mem_region = eLazyBoolCalculate; std::vector<std::pair<MemoryRegionInfo, FileSpec>> m_mem_region_cache; // Private Instance Methods NativeProcessNetBSD(::pid_t pid, int terminal_fd, NativeDelegate &delegate, const ArchSpec &arch, MainLoop &mainloop); bool HasThreadNoLock(lldb::tid_t thread_id); NativeThreadNetBSD &AddThread(lldb::tid_t thread_id); void MonitorCallback(lldb::pid_t pid, int signal); void MonitorExited(lldb::pid_t pid, WaitStatus status); void MonitorSIGSTOP(lldb::pid_t pid); void MonitorSIGTRAP(lldb::pid_t pid); void MonitorSignal(lldb::pid_t pid, int signal); Status PopulateMemoryRegionCache(); void SigchldHandler(); Status Attach(); Status ReinitializeThreads(); }; } // namespace process_netbsd } // namespace lldb_private #endif // #ifndef liblldb_NativeProcessNetBSD_H_
[ "stefan.teleman@cavium.com" ]
stefan.teleman@cavium.com
5e7e9832670b4b04db9e13f8fddea55903b4dcab
cf9b1d2a722fbfe90fea8043290d73e4597a0b8b
/C/tests/crypto/hash/csum/main.cpp
84c582d57f9071a80b3f3b229b43d7ef131a50c7
[]
no_license
cang-mang/TrueMan
965846a2c0df778b59f15f7fafba77e065073f3d
990b0aed45a9bacf15404077a8fa8cdafea5079a
refs/heads/main
2023-01-19T06:49:34.486102
2020-11-30T13:13:03
2020-11-30T13:13:03
311,609,648
0
0
null
null
null
null
UTF-8
C++
false
false
8,368
cpp
#include <trueman/crypto/hash.h> #include <iostream> #define TST_assert_eq(x, y) do { \ if((x) != (y)) { \ std::cout << "failure:" << std::endl; \ std::cout << "\t---- " << __FILE__ << ':' << __LINE__; \ std::cout << " (" << __FUNCTION__ << ") ----" << std::endl; \ std::cout << "\t left: " << (unsigned)(x) << std::endl; \ std::cout << "\tright: " << (unsigned)(y) << std::endl; \ return(-1); \ } \ } while(0) static const char TST_txt_0[] = ""; static const char TST_txt_1[] = "The quick brown fox jumps over the lazy dog"; static const char TST_txt_2[] = "The quick brown fox jumps over the lazy dog."; static const char TST_txt_3[] = "MIIEQwYJKoZIhvcNAQcCoIIENDCCBDACAQExCzAJBgUrDgMC" "GgUAMAsGCSqGSIb3DQEHAaCCAskwggLFMIIBraADAgECAgQ5" "oQecMA0GCSqGSIb3DQEBCwUAMBMxETAPBgNVBAMTCG1wYWFz" "MTIzMB4XDTE2MTEwMzEzMjMzNFoXDTQxMTAyODEzMjMzNFow" "EzERMA8GA1UEAxMIbXBhYXMxMjMwggEiMA0GCSqGSIb3DQEB" "AQUAA4IBDwAwggEKAoIBAQDNcuVBVv4Z+OGCg3nfrkLYf1Q7" "x+6gmZupGAh8DLews6NyfkXantLvYGz2KULNZimV8l6gzmHD" "HfmtJyOkgqXw+nl8dv4XQaZTRegtF3rnZt43Sc8ATBPGDjcx" "RkS4OU+NrkYvjCgy2Kqx77vQL44i552upjn2zeVuKPHPMa2e" "4brA3V5JkJFGI+UO6Kbi8UwpK6cZLOg2L6rjOMoo48ie2LcG" "SQ8R2WxSlxX2ShMbqIjiZUzuVIprvC1DdFHDJjnmwY9pO1gl" "SV40CWSHYIYc18IayA0Tp3ntGXsbvmK3DZaSDoAXSSWpd0up" "lw89eDlxDJooMrdya4E38c1LHFDxAgMBAAGjITAfMB0GA1Ud" "DgQWBBTv20iuBW5mZNCnVmLqaMDn1B9hazANBgkqhkiG9w0B" "AQsFAAOCAQEANS+tmgXPfqTkFnAlHMeypKhAa0sSTgpbe9gl" "9PzRBrqLxFxXeeJTF/FG+wDgLZYrJRl79jvnYY5glb0se7W6" "N0RYH1hgKlbZiWysVuoCxgzF9h6mpul/FFCRQyvg58CGrY01" "KaEmUWGAMZO8tH7rDsBvrRSpRx9xIiZE1EgnePTZeIABbY8R" "6SjM7Ar2mAgZ+Wtxtu0zCKsLkRGWrcFhzvYIedXltfK5s1ro" "DeGWXgDRPVUL1bVc2af8ABnBjHWJsVPYS2etHJuRSPZQLQX3" "cgt7W2NlnWShy1NvGSZeHlrpaoSj0qc9DZ+o5h2jimmYuU8I" "6mHmoLZNjFytnl/JNTGCAUIwggE+AgEBMBswEzERMA8GA1UE" "AxMIbXBhYXMxMjMCBDmhB5wwCQYFKw4DAhoFADANBgkqhkiG" "9w0BAQEFAASCAQB/IFTYMVWU5HapWkhoPcQaY+NEkN0JhKqN" "Jj0WWqgR8/56W3X/RRIc/PKnn9+WL7G7vJuXr3eLd8U/0NED" "W37dOebchoSkSAfDLrilCMJUbSlAGNHjffwwkVX3K0JKiV+j" "W795l7bRSaP++esblJZFxsbhwFhTST1XCFfm5jLH/PAvJakL" "tZV/uMWtguc/EHm3rhs3MaxSeCTn4qhxRIVunDRYi5xFg1UK" "WsaOnIJyMngnXZVQ509Qbbd4rcR9IZ6a2cyosbj9ehAlwD/Y" "M+WI64DJE+vBKhR7kjnZZQFkX/H+0hOuKountfiM3E+B87rR" "e2Ff4TSdA7262qZhvsYB"; static const char TST_txt_4[] = "In terms of practical security, a major concern " "about these new attacks is that they might pave the " "way to more efficient ones. Whether this is the case " "is yet to be seen, but a migration to stronger " "hashes is believed to be prudent. Some of the " "applications that use cryptographic hashes, like " "password storage, are only minimally affected by a " "collision attack. Constructing a password that works " "for a given account requires a preimage attack, as " "well as access to the hash of the original password, " "which may or may not be trivial. Reversing password " "encryption (e.g. to obtain a password to try against " "a user's account elsewhere) is not made possible by " "the attacks. (However, even a secure password hash " "can\'t prevent brute-force attacks on weak " "passwords.)"; static const char TST_txt_5[] = "0"; typedef union TST_ctx { std::uint8_t b[2]; std::uint16_t s; } TST_CTX_t; static void TST_csum(const void *ptr, std::uintptr_t len, std::uint8_t val[2]) { const std::uint8_t *buf = (const std::uint8_t *)ptr; TST_CTX_t ctx; std::uint32_t sum = 0; while(len > 1) { ctx.b[0] = *(buf++); ctx.b[1] = *(buf++); sum += ctx.s; len -= 2; } if(len) { sum += *buf; } while(sum >> 16) { sum = (sum >> 16) + (sum & 0x0000FFFF); } ctx.s = (std::uint16_t)(~sum); val[0] = ctx.b[0]; val[1] = ctx.b[1]; } static void TST_normal( const char *txt, std::uintptr_t len, std::uint8_t v_1[2], std::uint8_t v_2[2] ) { TrueMan::crypto::hash::csum::Ctx ctx; ctx.update(txt, len).final(v_1).update(txt, len).final(v_2); } static void TST_byte_by_byte( const char *txt, std::uintptr_t len, std::uint8_t v_1[2], std::uint8_t v_2[2] ) { TrueMan::crypto::hash::csum::Ctx ctx; std::uintptr_t cur = 0; for( ; cur < len; ++cur) { ctx.update(txt + cur, 1); } ctx.final(v_1); for(cur = 0; cur < len; ++cur) { ctx.update(txt + cur, 1); } ctx.final(v_2); } static void TST_one( const char *txt, std::uintptr_t len, std::uint8_t val[2] ) { TrueMan::crypto::hash::csum::op.one(txt, len, val); } static void TST_old( const char *txt, std::uintptr_t len, std::uint8_t val[2] ) { TST_csum(txt, len, val); } static int TST_exe(const char *txt, std::uintptr_t len, std::uint8_t const sum[2]) { std::uint8_t v_1[2] = { 0, 0 }; std::uint8_t v_2[2] = { 0, 0 }; TST_normal(txt, len, v_1, v_2); TST_assert_eq(v_1[0], sum[0]); TST_assert_eq(v_1[1], sum[1]); TST_assert_eq(v_2[0], sum[0]); TST_assert_eq(v_2[1], sum[1]); v_1[0] = 0; v_1[1] = 0; v_2[0] = 0; v_2[1] = 0; TST_byte_by_byte(txt, len, v_1, v_2); TST_assert_eq(v_1[0], sum[0]); TST_assert_eq(v_1[1], sum[1]); TST_assert_eq(v_2[0], sum[0]); TST_assert_eq(v_2[1], sum[1]); v_1[0] = 0; v_1[1] = 0; v_2[0] = 0; v_2[1] = 0; TST_one(txt, len, v_1); TST_old(txt, len, v_2); TST_assert_eq(v_1[0], sum[0]); TST_assert_eq(v_1[1], sum[1]); TST_assert_eq(v_2[0], sum[0]); TST_assert_eq(v_2[1], sum[1]); return(0); } int main(void) { std::cout << "len_ctx=" << TrueMan::crypto::hash::csum::op.len_ctx << std::endl; std::cout << "len_blk=" << TrueMan::crypto::hash::csum::op.len_blk << std::endl; std::cout << "len_dgt=" << TrueMan::crypto::hash::csum::op.len_dgt << std::endl; std::uint8_t val[2] = { 0xFF, 0xFF }; if(TST_exe(TST_txt_0, sizeof(TST_txt_0) - 1, val)) { std::cout << '\"' << TST_txt_0 << '\"' << std::endl; return(-1); } val[0] = 0x72; val[1] = 0xA4; if(TST_exe(TST_txt_1, sizeof(TST_txt_1) - 1, val)) { std::cout << '\"' << TST_txt_1 << '\"' << std::endl; return(-1); } val[0] = 0x72; val[1] = 0x76; if(TST_exe(TST_txt_2, sizeof(TST_txt_2) - 1, val)) { std::cout << '\"' << TST_txt_2 << '\"' << std::endl; return(-1); } val[0] = 0x77; val[1] = 0x70; if(TST_exe(TST_txt_3, sizeof(TST_txt_3) - 1, val)) { std::cout << '\"' << TST_txt_3 << '\"' << std::endl; return(-1); } val[0] = 0x05; val[1] = 0x03; if(TST_exe(TST_txt_4, sizeof(TST_txt_4) - 1, val)) { std::cout << '\"' << TST_txt_4 << '\"' << std::endl; return(-1); } val[0] = 0xCF; val[1] = 0xFF; if(TST_exe(TST_txt_5, sizeof(TST_txt_5) - 1, val)) { std::cout << '\"' << TST_txt_5 << '\"' << std::endl; return(-1); } std::cout << "OK " << '(' << __FUNCTION__ << ')' << std::endl; return(0); }
[ "cang.mang@foxmail.com" ]
cang.mang@foxmail.com
662f66dd087c55d6cc673258b7568bc8df74fd8f
8050bbeaf86021d5e89c7d81eedfd5ce0b391bb3
/Wolf.h
9aeba6bd2d7939c0b7d2e46023a66e22e18d12a3
[]
no_license
disneyyy/Wolf0828
fcf5fa57ff0ee3e3400e96fedf04ee924daa3813
a490e0f45ffa2c8e7289f22cef6f9b2547992a05
refs/heads/main
2023-08-01T01:02:14.280758
2021-09-23T03:45:18
2021-09-23T03:45:18
409,438,059
0
0
null
null
null
null
BIG5
C++
false
false
692
h
#ifndef WOLF_H #define WOLF_H #include "Character.h" #include <iostream> using namespace std; class Wolf: public Character{ public: Wolf(int m=10):Character(m){ } void skill(char *name){ cout<<"天黑請閉眼"<<endl; system("pause"); system("cls"); //狼人 殺掉的人要讓預言家這輪還能測 while(true){ system("cls"); cout<<"狼人請睜眼\n請問要殺哪位玩家?輸入該玩家號碼:"<<endl; cin>>decision; if(CheckName(decision, ' ', name)||decision>n||decision<1) continue; cout<<"玩家"<<decision<<"遭到殺害"<<endl; system("pause"); system("cls"); break; } } }; #endif
[ "noreply@github.com" ]
noreply@github.com
5d66baffab2c4b775d4de4c4f1845993e4e4e64e
8fd7669d4735ce43e3a81914a6a789c871865585
/concurrency_queue/scsp_list.h
1564fa3b35bddcf2c5366eedffb071cb458aae3a
[]
no_license
wsnk/concur
64148195b8da7b9c934d8ae4e3c86e37297be5cb
90a6373ccbcf3056d33c8e6747d88b6b7e3ef015
refs/heads/master
2021-05-11T18:10:03.012899
2018-01-17T10:00:25
2018-01-17T10:00:25
117,817,542
0
0
null
null
null
null
UTF-8
C++
false
false
2,422
h
#ifndef SCSP_LIST_H__ #define SCSP_LIST_H__ //------------------------------------------------------------------------------ #include <atomic> #include <memory> #include <new> //------------------------------------------------------------------------------ template < typename T > struct SCSPListItem { typedef std::atomic< SCSPListItem< T > * > Next; Next next; T data; }; //------------------------------------------------------------------------------ template < typename T, typename Allocator = std::allocator< SCSPListItem<T> > > class SCSPList { public: typedef T ElementType; typedef SCSPListItem< T > ListItem; public: SCSPList() : fRead(&fRoot), fTail(&fRoot) { fRoot.next = &fRoot; } ~SCSPList() { Allocator allocator; auto ptr = fRoot.next.load(std::memory_order_relaxed); while (ptr != &fRoot) { auto const next = ptr->next.load(std::memory_order_relaxed); ptr->~ListItem(); allocator.deallocate(ptr, 1); ptr = next; } } bool consume(T &aOut) { bool success = false; auto const read = fRead.load(std::memory_order_relaxed); auto const next = read->next.load(std::memory_order_relaxed); if (&fRoot != next) { aOut = std::move(next->data); fRead.store(next, std::memory_order_relaxed); success = true; } return success; } void produce(T const &aIn) { emplace(aIn); } template < typename... Args > void emplace(Args&&... aArgs) { Allocator allocator; // push auto newItem = allocator.allocate(1); new( &(newItem->next) ) typename ListItem::Next(); newItem->next.store(&fRoot, std::memory_order_relaxed); new( &(newItem->data) ) T(std::forward< Args >(aArgs)...); fTail->next.store(newItem, std::memory_order_relaxed); fTail = newItem; // garbage collect auto const read = fRead.load(std::memory_order_relaxed); if (read != &fRoot) { ListItem *erase = fRoot.next.load(std::memory_order_relaxed); fRoot.next.store(read, std::memory_order_relaxed); while (erase != read) { auto const next = erase->next.load(std::memory_order_relaxed); erase->~ListItem(); allocator.deallocate(erase, 1); erase = next; } } } private: ListItem fRoot; std::atomic< ListItem * > fRead; ListItem *fTail; }; //------------------------------------------------------------------------------ #endif
[ "m.samokhin@3atelecom.ru" ]
m.samokhin@3atelecom.ru
8b15d017728bd3cba4f0e85a6c7ac10af96a3ed5
3d07ae0b0ea8061af97e067c61fc26c63f21927f
/oneflow/core/framework/tensor.cpp
bfc23a043b1e06b32b7fb0096cf7f2842f248ccf
[ "Apache-2.0" ]
permissive
maybemind/oneflow
2a64843feb2c1169d9a2c4230f2e786f1f9cd4a0
95767e1e28b666e59d7b31018ffbcf30ab5b8db9
refs/heads/master
2023-04-06T04:45:54.957527
2021-04-12T11:29:43
2021-04-12T11:29:43
309,308,152
0
0
Apache-2.0
2021-04-12T11:29:44
2020-11-02T08:43:47
null
UTF-8
C++
false
false
3,978
cpp
/* Copyright 2020 The OneFlow Authors. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "oneflow/core/framework/tensor.h" #include "oneflow/core/job/parallel_desc.h" #include "oneflow/core/framework/device.h" #include "oneflow/core/framework/dtype.h" #include "oneflow/core/autograd/autograd_engine.h" namespace oneflow { namespace one { std::shared_ptr<MirroredTensor> MirroredTensor::MakeTensor( const std::shared_ptr<const Shape>& shape, const std::shared_ptr<const DType>& dtype, const std::shared_ptr<const Device>& device, bool is_lazy, bool requires_grad, bool is_leaf, bool retain_grad) { std::shared_ptr<MirroredTensorImpl> impl; if (is_lazy) { impl = std::make_shared<LazyMirroredTensorImpl>(shape, dtype, device, requires_grad, is_leaf, retain_grad); } else { impl = std::make_shared<EagerMirroredTensorImpl>(shape, dtype, device, requires_grad, is_leaf, retain_grad); } return std::make_shared<MirroredTensor>(impl); } bool MirroredTensor::is_cuda() const { return device()->type() == "cuda"; } int64_t MirroredTensor::ndim() const { return shape()->NumAxes(); } int64_t MirroredTensor::dim(int64_t index) const { return shape()->At(index); } int64_t MirroredTensor::nelement() const { return shape()->elem_cnt(); } std::shared_ptr<MirroredTensor> MirroredTensor::data() const { std::shared_ptr<MirroredTensor> t = MakeTensor(shape(), dtype(), device(), is_lazy(), false, is_leaf(), false); t->set_blob_object(blob_object()); return t; } std::shared_ptr<Tensor> MirroredTensor::detach() const { std::shared_ptr<MirroredTensor> t = std::make_shared<MirroredTensor>(impl_); return t; } std::shared_ptr<ConsistentTensor> ConsistentTensor::MakeTensor( const std::shared_ptr<const Shape>& shape, const std::shared_ptr<const DType>& dtype, const std::shared_ptr<const compatible_py::Distribute>& distribute, const std::shared_ptr<const ParallelDesc>& parallel_desc, bool is_lazy, bool requires_grad, bool is_leaf, bool retain_grad) { std::shared_ptr<ConsistentTensorImpl> impl; if (is_lazy) { impl = std::make_shared<LazyConsistentTensorImpl>(shape, dtype, distribute, parallel_desc, requires_grad, is_leaf, retain_grad); } else { impl = std::make_shared<EagerConsistentTensorImpl>(shape, dtype, distribute, parallel_desc, requires_grad, is_leaf, retain_grad); } return std::make_shared<ConsistentTensor>(impl); } bool ConsistentTensor::is_cuda() const { return parallel_desc()->device_type() == DeviceType::kGPU; } int64_t ConsistentTensor::dim(int64_t index) const { return shape()->At(index); } int64_t ConsistentTensor::nelement() const { return shape()->elem_cnt(); } int64_t ConsistentTensor::ndim() const { return shape()->NumAxes(); } std::shared_ptr<ConsistentTensor> ConsistentTensor::data() const { std::shared_ptr<ConsistentTensor> t = MakeTensor(shape(), dtype(), distribute(), parallel_desc(), is_lazy(), false, is_leaf(), false); t->set_blob_object(blob_object()); return t; } std::shared_ptr<Tensor> ConsistentTensor::detach() const { std::shared_ptr<ConsistentTensor> t = std::make_shared<ConsistentTensor>(impl_); return t; } } // namespace one } // namespace oneflow
[ "noreply@github.com" ]
noreply@github.com
7220b31474c2794e835af31d6eaa1156be0be76d
e2d944669d9935ec25aac1920a613b4d3edf1713
/kasten/controllers/view/print/printcontrollerfactory.hpp
04098eece738106940bba074eea7ba2ac510364f
[]
no_license
wushangshikongyonghengdazizai/okteta
6e87cfec2585a2a763b33dcda02d8b4a33a2b0af
4172a54a982d38c90878fb48cdf0f9174a19aa98
refs/heads/master
2023-02-05T01:09:42.305518
2020-12-26T14:38:54
2020-12-26T14:38:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
820
hpp
/* This file is part of the Okteta Kasten module, made within the KDE community. SPDX-FileCopyrightText: 2019 Friedrich W. H. Kossebau <kossebau@kde.org> SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #ifndef KASTEN_PRINTCONTROLLERFACTORY_HPP #define KASTEN_PRINTCONTROLLERFACTORY_HPP // lib #include <kasten/okteta/oktetakastencontrollers_export.hpp> // Kasten core #include <Kasten/AbstractXmlGuiControllerFactory> namespace Kasten { class OKTETAKASTENCONTROLLERS_EXPORT PrintControllerFactory : public AbstractXmlGuiControllerFactory { public: PrintControllerFactory(); ~PrintControllerFactory() override; public: // AbstractXmlGuiControllerFactory API AbstractXmlGuiController* create(KXMLGUIClient* guiClient) const override; }; } #endif
[ "kossebau@kde.org" ]
kossebau@kde.org
0fe2afbfc8cec3f770f7159d1ca17f99340fce6f
7f00bfe45e7117c831b0b3cb4a2f1b869e6a0129
/convert/main.cpp
2032df0a5dff17ad2a889bf84c4b1b238ace7e51
[]
no_license
tenmachow/cameratest
c973ace4681ede19e895454ff9f83d0a5af614a7
6d5a0d49f9e7508de784655efc9081f3524486bb
refs/heads/master
2021-01-19T00:14:28.050822
2012-09-14T01:28:33
2012-09-14T01:28:33
5,684,302
0
1
null
null
null
null
UTF-8
C++
false
false
671
cpp
#include <stdio.h> #include <stdarg.h> #include <stdlib.h> #include <string> #include <iostream> #include <linux/videodev2.h> #include "convertor.h" #include "convertor_registry.h" /** * Prints a failure message and exists * * @param fmt C format string followed by additional arguments */ void failure(const char *fmt, ...) { va_list args; va_start(args, fmt); vfprintf(stderr, fmt, args); va_end(args); printf("\n"); exit(1); } int main(int argc, char *argv[]) { convertor* con; con = convertor_registry::get_convertor(V4L2_PIX_FMT_YUYV, V4L2_PIX_FMT_RGB24, 720); int width = con->get_width(); std::cout << "Width: " << width << std::endl; return 0; }
[ "tenmachow@gmail.com" ]
tenmachow@gmail.com
16252a006821deaf03a268a3392fd5d0766cd80b
e50b5f066628ef65fd7f79078b4b1088f9d11e87
/llvm/tools/clang/include/clang/AST/ASTConsumer.h
adcf6d719dda0994a231c895658cf1133ae5633c
[ "NCSA" ]
permissive
uzleo/coast
1471e03b2a1ffc9883392bf80711e6159917dca1
04bd688ac9a18d2327c59ea0c90f72e9b49df0f4
refs/heads/master
2020-05-16T11:46:24.870750
2019-04-23T13:57:53
2019-04-23T13:57:53
183,025,687
0
0
null
2019-04-23T13:52:28
2019-04-23T13:52:27
null
UTF-8
C++
false
false
6,122
h
//===--- ASTConsumer.h - Abstract interface for reading ASTs ----*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file defines the ASTConsumer class. // //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_AST_ASTCONSUMER_H #define LLVM_CLANG_AST_ASTCONSUMER_H #include "llvm/ADT/StringRef.h" namespace clang { class ASTContext; class CXXMethodDecl; class CXXRecordDecl; class Decl; class DeclGroupRef; class ASTMutationListener; class ASTDeserializationListener; // layering violation because void* is ugly class SemaConsumer; // layering violation required for safe SemaConsumer class TagDecl; class VarDecl; class FunctionDecl; class ImportDecl; /// ASTConsumer - This is an abstract interface that should be implemented by /// clients that read ASTs. This abstraction layer allows the client to be /// independent of the AST producer (e.g. parser vs AST dump file reader, etc). class ASTConsumer { /// \brief Whether this AST consumer also requires information about /// semantic analysis. bool SemaConsumer; friend class SemaConsumer; public: ASTConsumer() : SemaConsumer(false) { } virtual ~ASTConsumer() {} /// Initialize - This is called to initialize the consumer, providing the /// ASTContext. virtual void Initialize(ASTContext &Context) {} /// HandleTopLevelDecl - Handle the specified top-level declaration. This is /// called by the parser to process every top-level Decl*. /// /// \returns true to continue parsing, or false to abort parsing. virtual bool HandleTopLevelDecl(DeclGroupRef D); /// \brief This callback is invoked each time an inline (method or friend) /// function definition in a class is completed. virtual void HandleInlineFunctionDefinition(FunctionDecl *D) {} /// HandleInterestingDecl - Handle the specified interesting declaration. This /// is called by the AST reader when deserializing things that might interest /// the consumer. The default implementation forwards to HandleTopLevelDecl. virtual void HandleInterestingDecl(DeclGroupRef D); /// HandleTranslationUnit - This method is called when the ASTs for entire /// translation unit have been parsed. virtual void HandleTranslationUnit(ASTContext &Ctx) {} /// HandleTagDeclDefinition - This callback is invoked each time a TagDecl /// (e.g. struct, union, enum, class) is completed. This allows the client to /// hack on the type, which can occur at any point in the file (because these /// can be defined in declspecs). virtual void HandleTagDeclDefinition(TagDecl *D) {} /// \brief This callback is invoked the first time each TagDecl is required to /// be complete. virtual void HandleTagDeclRequiredDefinition(const TagDecl *D) {} /// \brief Invoked when a function is implicitly instantiated. /// Note that at this point point it does not have a body, its body is /// instantiated at the end of the translation unit and passed to /// HandleTopLevelDecl. virtual void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D) {} /// \brief Handle the specified top-level declaration that occurred inside /// and ObjC container. /// The default implementation ignored them. virtual void HandleTopLevelDeclInObjCContainer(DeclGroupRef D); /// \brief Handle an ImportDecl that was implicitly created due to an /// inclusion directive. /// The default implementation passes it to HandleTopLevelDecl. virtual void HandleImplicitImportDecl(ImportDecl *D); /// CompleteTentativeDefinition - Callback invoked at the end of a translation /// unit to notify the consumer that the given tentative definition should be /// completed. /// /// The variable declaration itself will be a tentative /// definition. If it had an incomplete array type, its type will /// have already been changed to an array of size 1. However, the /// declaration remains a tentative definition and has not been /// modified by the introduction of an implicit zero initializer. virtual void CompleteTentativeDefinition(VarDecl *D) {} /// \brief Callback invoked when an MSInheritanceAttr has been attached to a /// CXXRecordDecl. virtual void AssignInheritanceModel(CXXRecordDecl *RD) {} /// HandleCXXStaticMemberVarInstantiation - Tell the consumer that this // variable has been instantiated. virtual void HandleCXXStaticMemberVarInstantiation(VarDecl *D) {} /// \brief Callback involved at the end of a translation unit to /// notify the consumer that a vtable for the given C++ class is /// required. /// /// \param RD The class whose vtable was used. virtual void HandleVTable(CXXRecordDecl *RD) {} /// \brief If the consumer is interested in entities getting modified after /// their initial creation, it should return a pointer to /// an ASTMutationListener here. virtual ASTMutationListener *GetASTMutationListener() { return nullptr; } /// \brief If the consumer is interested in entities being deserialized from /// AST files, it should return a pointer to a ASTDeserializationListener here virtual ASTDeserializationListener *GetASTDeserializationListener() { return nullptr; } /// PrintStats - If desired, print any statistics. virtual void PrintStats() {} /// \brief This callback is called for each function if the Parser was /// initialized with \c SkipFunctionBodies set to \c true. /// /// \return \c true if the function's body should be skipped. The function /// body may be parsed anyway if it is needed (for instance, if it contains /// the code completion point or is constexpr). virtual bool shouldSkipFunctionBody(Decl *D) { return true; } }; } // end namespace clang. #endif
[ "jeffrey.goeders@gmail.com" ]
jeffrey.goeders@gmail.com
12ba12795fdd208cd48cb5b86270d7d9bf8f78ca
16807220b95bf9a559b97ec0de16665ff31823cb
/serial/seriald/device_list.h
c0cf6aeeac7db3191235ec7e6ff825f2126a800e
[ "BSD-3-Clause" ]
permissive
cuauv/software
7263df296e01710cb414d340d8807d773c3d8e23
5ad4d52d603f81a7f254f365d9b0fe636d03a260
refs/heads/master
2021-12-22T07:54:02.002091
2021-11-18T01:26:12
2021-11-18T02:37:55
46,245,987
76
34
null
2016-08-03T05:31:00
2015-11-16T02:02:36
C++
UTF-8
C++
false
false
1,247
h
#pragma once #include <memory> #include <unordered_set> #include <unordered_map> #include <mutex> #include <thread> #include "config.h" #include "sub_status.h" #include "device.h" class DeviceList { public: DeviceList(const std::shared_ptr<Config> config, std::shared_ptr<SubStatus> subStatus); ~DeviceList(); void onDeviceDisconnect(std::string deviceName); void claimVarWriter(std::string deviceName, std::string shmPath); bool disconnecting(); private: std::recursive_mutex m_mutex; std::unordered_map<std::string, std::shared_ptr<Device>> m_disabledDevices; std::unordered_map<std::string, std::shared_ptr<Device>> m_runningDevices; std::unordered_map<std::string, std::shared_ptr<cuauv::serial::Manager>> m_ports; std::unordered_map<cuauv::serial::Manager*, std::string> m_portOwners; // port -> device name std::unordered_map<std::string, std::string> m_varWriters; // shm path -> device name std::thread m_portDeleter; bool m_disconnecting; std::shared_ptr<cuauv::serial::DeviceCallbacks> onPortConnect(cuauv::serial::Manager* port, std::shared_ptr<cuauv::serial::DeviceInfo> deviceInfo); void onPortFailure(cuauv::serial::Manager* port, std::string error); void deletePort(std::string name); };
[ "leader@cuauv.org" ]
leader@cuauv.org
a3f35b3bfaf42dc8061296f336ee8500a9c9da9f
8b56aa7a8deb23315a6ad687c902e43031f9bdc9
/PrettyShore_Source/AI/BehaviourTree/Tasks/BTTask_AIBeach_FailedToExecuteTask.cpp
2c95f1af61871199cfeb1f9c3dda61523f5e9f9f
[]
no_license
Tarfax/PortfolioProjects
6a02b388cfedf51102f94047d52f77235a0242d0
2cd4b373f396aec8d56db71cabc04de9c47df9e5
refs/heads/master
2023-08-21T17:19:34.532945
2021-10-14T07:55:52
2021-10-14T07:55:52
20,998,621
0
0
null
null
null
null
UTF-8
C++
false
false
1,290
cpp
#include "BTTask_AIBeach_FailedToExecuteTask.h" #include "Team9Assemble/AI/AIVisitor/AIVisitor_Controller.h" #include "Team9Assemble/AI/AILifeguard//AILifeGuard_Controller.h" UBTTask_AIBeach_FailedToExecuteTask::UBTTask_AIBeach_FailedToExecuteTask() { NodeName = "AIBeach Failed To Execute Task"; } void UBTTask_AIBeach_FailedToExecuteTask::OnGameplayTaskActivated(UGameplayTask& Task) {} EBTNodeResult::Type UBTTask_AIBeach_FailedToExecuteTask::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) { if (AIType == EAIType::Visitor) { AAIVisitor_Controller* Visitor = Cast<AAIVisitor_Controller>(OwnerComp.GetAIOwner()); Visitor->FailedToExecuteTask(VisitorBehaviourState, LockdownTime); } else { AAILifeGuard_Controller* LifeGuard = Cast<AAILifeGuard_Controller>(OwnerComp.GetAIOwner()); LifeGuard->FailedToExecuteTask(LifeGuardBehaviourState, LockdownTime); } // // AAIBeach_Controller_Base* AIBeach = Cast<AAIBeach_Controller_Base>(OwnerComp.GetAIOwner()); // // AIBeach->FailedToExecuteTask(); return EBTNodeResult::Failed; } void UBTTask_AIBeach_FailedToExecuteTask::InitializeFromAsset(UBehaviorTree& Asset) {} void UBTTask_AIBeach_FailedToExecuteTask::TickTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds) {}
[ "lostmike@gmail.com" ]
lostmike@gmail.com
2a8e7ec3498d732856b076bef0ca87f7d77aea12
66862c422fda8b0de8c4a6f9d24eced028805283
/cmake-3.17.5/Source/cmInstallTargetGenerator.h
e21001f888a89ca1072c6bd8e577d6ebf16090a9
[ "MIT", "BSD-3-Clause" ]
permissive
zhh2005757/slambook2_in_Docker
57ed4af958b730e6f767cd202717e28144107cdb
f0e71327d196cdad3b3c10d96eacdf95240d528b
refs/heads/main
2023-09-01T03:26:37.542232
2021-10-27T11:45:47
2021-10-27T11:45:47
416,666,234
17
6
MIT
2021-10-13T09:51:00
2021-10-13T09:12:15
null
UTF-8
C++
false
false
4,581
h
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ #ifndef cmInstallTargetGenerator_h #define cmInstallTargetGenerator_h #include "cmConfigure.h" // IWYU pragma: keep #include <iosfwd> #include <string> #include <vector> #include "cmInstallGenerator.h" #include "cmListFileCache.h" #include "cmScriptGenerator.h" class cmGeneratorTarget; class cmLocalGenerator; /** \class cmInstallTargetGenerator * \brief Generate target installation rules. */ class cmInstallTargetGenerator : public cmInstallGenerator { public: cmInstallTargetGenerator( std::string targetName, std::string const& dest, bool implib, std::string file_permissions, std::vector<std::string> const& configurations, std::string const& component, MessageLevel message, bool exclude_from_all, bool optional, cmListFileBacktrace backtrace = cmListFileBacktrace()); ~cmInstallTargetGenerator() override; /** Select the policy for installing shared library linkable name symlinks. */ enum NamelinkModeType { NamelinkModeNone, NamelinkModeOnly, NamelinkModeSkip }; void SetNamelinkMode(NamelinkModeType mode) { this->NamelinkMode = mode; } NamelinkModeType GetNamelinkMode() const { return this->NamelinkMode; } std::string GetInstallFilename(const std::string& config) const; void GetInstallObjectNames(std::string const& config, std::vector<std::string>& objects) const; enum NameType { NameNormal, NameImplib, NameSO, NameReal }; static std::string GetInstallFilename(const cmGeneratorTarget* target, const std::string& config, NameType nameType = NameNormal); bool Compute(cmLocalGenerator* lg) override; cmGeneratorTarget* GetTarget() const { return this->Target; } bool IsImportLibrary() const { return this->ImportLibrary; } std::string GetDestination(std::string const& config) const; cmListFileBacktrace const& GetBacktrace() const { return this->Backtrace; } protected: void GenerateScriptForConfig(std::ostream& os, const std::string& config, Indent indent) override; void GenerateScriptForConfigObjectLibrary(std::ostream& os, const std::string& config, Indent indent); using TweakMethod = void (cmInstallTargetGenerator::*)(std::ostream&, Indent, const std::string&, const std::string&); void AddTweak(std::ostream& os, Indent indent, const std::string& config, std::string const& file, TweakMethod tweak); void AddTweak(std::ostream& os, Indent indent, const std::string& config, std::vector<std::string> const& files, TweakMethod tweak); std::string GetDestDirPath(std::string const& file); void PreReplacementTweaks(std::ostream& os, Indent indent, const std::string& config, std::string const& file); void PostReplacementTweaks(std::ostream& os, Indent indent, const std::string& config, std::string const& file); void AddInstallNamePatchRule(std::ostream& os, Indent indent, const std::string& config, const std::string& toDestDirPath); void AddChrpathPatchRule(std::ostream& os, Indent indent, const std::string& config, std::string const& toDestDirPath); void AddRPathCheckRule(std::ostream& os, Indent indent, const std::string& config, std::string const& toDestDirPath); void AddStripRule(std::ostream& os, Indent indent, const std::string& toDestDirPath); void AddRanlibRule(std::ostream& os, Indent indent, const std::string& toDestDirPath); void AddUniversalInstallRule(std::ostream& os, Indent indent, const std::string& toDestDirPath); void IssueCMP0095Warning(const std::string& unescapedRpath); std::string const TargetName; cmGeneratorTarget* Target; std::string const FilePermissions; NamelinkModeType NamelinkMode; bool const ImportLibrary; bool const Optional; cmListFileBacktrace const Backtrace; }; #endif
[ "594353397@qq.com" ]
594353397@qq.com
5610395a20322db410cc984bf8c84cc60d8862aa
c402fbb9dac63736403567ab5f63c37cdf15f217
/QT_Core_Intermediate/QTAssignment1/test.cpp
5edf7f7aa046cbca5974a188ee110c6c3ca10aa6
[]
no_license
ChrisTayl2018/Qt_tutorials
311d1c5f79d20541dcc372f11718a69ef5fe40cf
6a41b27c734fef16757b961da9006ffe2e811c92
refs/heads/master
2022-10-09T23:45:09.260279
2020-06-10T07:14:17
2020-06-10T07:14:17
268,945,900
0
0
null
null
null
null
UTF-8
C++
false
false
198
cpp
#include "test.h" #include <QDebug> test::test(QObject *parent) : QObject(parent) { qInfo() << "Constructed object" << this; } test::~test() { qInfo() << "Deconstructed object" << this; }
[ "ctaylor1991@live.com.au" ]
ctaylor1991@live.com.au
6bdbcaef6ff380b150162bfdf202b12b070e3295
32afec3a4b4c226573593fb7701f9e412e4f9596
/openikcape/uom/uom.cpp
c398a84c24f813c823084390c12e24df4f96cda7
[ "MIT" ]
permissive
E452003/openikcape
00d144438e014c2512c07960ef5ce16bbd315d19
7612a7c68237920373c11f137130d74f7ad134eb
refs/heads/master
2023-01-21T20:02:18.831553
2020-12-03T21:45:08
2020-12-03T21:45:08
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,841
cpp
#include <string> #include <vector> #include <stdexcept> #include <math.h> #include <map> #include "uom.h" using namespace std; namespace Thermodynamics { namespace UOM { double Unit::get_conversion_factor(Unit other) { return this->factor / other.factor; } double Unit::convert_value(double value, Unit target) { double baseValue = this->factor * value + this->offset; return (baseValue - target.offset) / target.factor; } Unit Unit::operator*(const Unit rhs) { auto newDims = std::array<double, 8>(); for (int i = 0; i < 8; i++) { newDims[i] = this->dimensions[i] + rhs.dimensions[i]; } return Unit(this->symbol + "*" + rhs.symbol, "Derived Unit", newDims, this->factor * rhs.factor, this->offset + rhs.offset); } Unit Unit::operator/(const Unit rhs) { auto newDims = std::array<double, 8>(); for (int i = 0; i < 8; i++) { newDims[i] = this->dimensions[i] - rhs.dimensions[i]; } return Unit(this->symbol + "/" + rhs.symbol, "Derived Unit", newDims, this->factor / rhs.factor, this->offset - rhs.offset); } Unit Unit::operator^(double rhs) { auto newDims = std::array<double, 8>(); for (int i = 0; i < 8; i++) { newDims[i] = this->dimensions[i] * rhs; } return Unit(this->symbol + "^" + std::to_string(rhs), "Derived Unit", newDims, this->factor, this->offset); } Unit::operator std::string() const { return this->symbol; } } // namespace UOM } // namespace Thermodynamics
[ "jochen.steimel@googlemail.com" ]
jochen.steimel@googlemail.com
1f4e426683b060eb65a3b81f763b70c06d698b9d
3a9dd58f5b1b5e1f54c74b76543e0405faac9804
/block_world(完成)/block_world.cpp
4e5702f9c159f23b5420f5f4d75acc04638e58cc
[]
no_license
FrostKong/-
c0a4483f15a210a1b00d855814da239bb82a3e5a
1db36728fcaa7564afbcc5a3a598ebd406cd8064
refs/heads/master
2020-05-07T11:46:14.923314
2019-04-10T01:16:40
2019-04-10T01:16:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,728
cpp
// block_world.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 // #include "pch.h" #include <iostream> #include <string> #include <cstring> #include <vector> #define maxn 25 using namespace std; vector<int> pile[maxn]; //全局 int n; //全局 n=pile number void find_num( int a,int &temp_i,int &temp_j) { // for (temp_i = 0; temp_i < n; temp_i++) { for (temp_j = 0; temp_j < pile[temp_i].size(); temp_j++) { if (pile[temp_i][temp_j] == a) return ; //0也没有 } } } void go_origin(int a,int temp_i,int temp_j) { //不允许使用引用的数组 //c++ primer 4 中明确讲到是可以使用数组的引用的函数定义形式: void f((&a)[5]) int i; while (pile[temp_i].back() != a) { i = pile[temp_i].back(); pile[temp_i].pop_back(); pile[i].push_back(i);//pile[p].resize(h + 1); pile 只应保留下标0~h 的元素,这个也可以用 } } void add_num(int a, int temp_ai,int temp_aj, int temp_bi) { int j; if (pile[temp_ai].size() == 0) { return; } if (pile[temp_ai].back() == a) { pile[temp_bi].push_back(a); pile[temp_ai].pop_back(); return; } j = pile[temp_ai].size(); for (int i = temp_aj; i < j; i++) { pile[temp_bi].push_back(pile[temp_ai][i]); } for (int i = temp_aj; i < j; i++) { pile[temp_ai].pop_back(); } } void go_front(int b, int temp_i, vector<int>(&pile)[maxn]) { //b的位置 int i2; while (pile[temp_i].back() != b) { i2 = pile[temp_i].back(); pile[i2].insert(pile[i2].begin(), i2); pile[temp_i].pop_back(); } } int main() { int temp_ai, temp_aj, temp_bi, temp_bj; cin >> n; char c[5], c2[5]; //cin只能读入char风格字符串,而cin.getline可以读入string int a, b; //可能会有24的两位数 for (int i = 0; i < n; i++) { pile[i].push_back(i); } while(1) {//实际只能读取size-1个数据 ,while (cin.getline(s, 5))用不了 cin >> c; if (!strcmp(c, "quit")) { break; } cin >> a >> c2 >> b; if (a == b) continue; find_num(a, temp_ai, temp_aj); find_num(b, temp_bi, temp_bj); if (temp_ai == temp_bi) continue; if (!strcmp(c, "move")) { //这个为什么不行strcmp(s.substr(0, 3),"move"), //因为返回值有问题,需要赋给一个指向常量字符串的指针 go_origin(a, temp_ai, temp_aj); if (!strcmp(c2, "onto")) go_origin(b, temp_bi, temp_bj); } else { // if (!strcmp(c2, "onto")) go_front(b, temp_bi, pile); } add_num(a, temp_ai, temp_aj, temp_bi); } for (int i = 0; i < n; i++) { cout << i << ":"; for (int j = 0; j < pile[i].size(); j++) { cout << " " << pile[i][j]; } cout << endl; } return 0; }
[ "noreply@github.com" ]
noreply@github.com
50d29826e651aae5064bc616a5f8ce5502ecc276
1019e8d5e5c775ae6e6eeea07814701358b2b339
/contest1/passwords/main.cpp
103c302bf3cf1c63b9cbd4637198f6a8c3d334b1
[]
no_license
tomasmor42/olya_learns_cpp
62ffa81065731a8b4919331fccdf244f6819e697
dbd51c1a80c5ace01a19eef914c3195fef6d3fb2
refs/heads/main
2023-04-12T15:45:34.029812
2021-05-13T18:24:15
2021-05-13T18:24:15
359,925,569
0
0
null
null
null
null
UTF-8
C++
false
false
2,783
cpp
#include <iostream> int hasCapitalLetters(std::string pwd){ if (true) { int count = 0; for(int i = 65; i <= 90; i++) { char c = (char)i; std::string str1(1, c); if (pwd.find(str1) != std::string::npos) count = 1; } if (count == 0) return 0; else {return 1;} } } int hasSmallLetters(std::string pwd){ if (true) { int count = 0; for(int i = 97; i <= 122; i++) { char c = (char)i; std::string str1(1, c); if (pwd.find(str1) != std::string::npos) count = 1; } if (count == 0) return 0; else {return 1;} } } int hasDigits(std::string pwd){ if (true) { int count = 0; for(int i = 48; i <= 57; i++) { char c = (char)i; std::string str1(1, c); if (pwd.find(str1) != std::string::npos) count = 1; } if (count == 0) return 0; else {return 1;} } } int hasOther(std::string pwd){ if (true) { int count = 0; for(int i = 33; i <= 47; i++) { char c = (char)i; std::string str1(1, c); if (pwd.find(str1) != std::string::npos) count = 1; } for(int i = 58; i <= 63; i++) { char c = (char)i; std::string str1(1, c); if (pwd.find(str1) != std::string::npos) count = 1; } for(int i = 91; i <= 96; i++) { char c = (char)i; std::string str1(1, c); if (pwd.find(str1) != std::string::npos) count = 1; } for(int i = 123; i <= 126; i++) { char c = (char)i; std::string str1(1, c); if (pwd.find(str1) != std::string::npos) count = 1; } if (count == 0) return 0; else {return 1;} } } int main() { std::string pwd; std::cin >> pwd; if (pwd.length() < 8 or pwd.length() > 13){ std::cout << "NO" << std::endl; return 0; } for (long unsigned int i = 0; i < pwd.size(); i++) { if ((int)pwd[i] < 33 or (int)pwd[i] > 126){ std::cout << "NO" << std::endl; return 0; } } if (hasCapitalLetters(pwd) + hasSmallLetters(pwd) + hasOther(pwd) + hasDigits(pwd) >= 3){ std::cout << "YES" << std::endl; return 0; } std::cout << "NO" << std::endl; return 0; }
[ "tomasmor42@gmail.com" ]
tomasmor42@gmail.com
6f84ec333b286102cfccf51bc6876c281b9ab464
15727e99c9f596a9d7829e819593a3204eeca152
/Firmware/firmware_tests/stubs/widgets_stub_pages_creator.cpp
31e3caca0dbd7ad965ba8b65f597effaee1433ec
[ "MIT" ]
permissive
ValentiWorkLearning/GradWork
c6b899988000bdef9b167ed18326cd1623ce5985
801f99277986aba1f3930cf73d7f1bdf372cd37e
refs/heads/master
2023-04-08T10:43:56.522352
2021-12-31T01:40:46
2021-12-31T01:40:46
210,127,142
47
8
MIT
2022-11-19T23:41:37
2019-09-22T10:13:59
C
UTF-8
C++
false
false
1,062
cpp
#include "widgets_stub_pages_creator.hpp" #include "battery_widget_fake.hpp" #include "bluetooth_widget_fake.hpp" #include "pages_switch_widget_fake.hpp" namespace Graphics::StubWidgets { StubWidgetsCreator::~StubWidgetsCreator() = default; std::unique_ptr<Graphics::Widgets::IBluetoothWidget> StubWidgetsCreator::createBluetoothWidget( Graphics::Theme::IThemeController* _pThemeController) noexcept { return std::make_unique<BluetoothWidgetStub>(); } std::unique_ptr<Graphics::Widgets::IPagesSwitch> StubWidgetsCreator::createPagesSwitchWidget( Graphics::Theme::IThemeController* _pThemeController) noexcept { return std::make_unique<PagesSwitchWidgetStub>(); } std::unique_ptr<Graphics::Widgets::IBatteryWidget> StubWidgetsCreator::createBatteryWidget( Graphics::Theme::IThemeController* _pThemeController) noexcept { return std::make_unique<BatteryWidgetStub>(); } Graphics::Widgets::IWidgetsCreator::Ptr createStubWidgetsCreator() noexcept { return std::make_unique<StubWidgetsCreator>(); } } // namespace Graphics::StubWidgets
[ "kornienko-vr@rambler.ru" ]
kornienko-vr@rambler.ru
0cfbbd95396e15fedfb51c388011746efd8e2577
0ff3961fab3d7aac799c9555853ef141ffe38eb1
/Dev/Segmentation/SegmentationCore/MRF/src/ICM.cpp
724cc1bcb148cc4547eb4d6034cb0735debced5e
[]
no_license
liupeng625/DevBundle
d8f8ff5a78730645e91a1a2a9c328c426f9deaa6
daee1ace1fc929f629d2c916aee2922a02b41493
refs/heads/master
2021-03-12T01:55:17.966697
2018-09-13T10:04:38
2018-09-13T10:04:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,668
cpp
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include "MRF/include/ICM.h" #define m_D(pix,l) m_D[(pix)*m_nLabels+(l)] #define m_V(l1,l2) m_V[(l1)*m_nLabels+(l2)] ICM::ICM(int width, int height, int nLabels,EnergyFunction *eng):MRF(width,height,nLabels,eng) { m_needToFreeV = 0; initializeAlg(); } ICM::ICM(int nPixels, int nLabels,EnergyFunction *eng):MRF(nPixels,nLabels,eng) { m_needToFreeV = 0; initializeAlg(); } ICM::~ICM() { delete[] m_answer; if (!m_grid_graph) delete[] m_neighbors; if ( m_needToFreeV ) delete[] m_V; } void ICM::initializeAlg() { m_answer = (Label *) new Label[m_nPixels]; if ( !m_answer ){printf("\nNot enough memory, exiting");exit(0);} if (!m_grid_graph) { m_neighbors = (LinkedBlockList *) new LinkedBlockList[m_nPixels]; if (!m_neighbors) {printf("Not enough memory,exiting");exit(0);}; } } void ICM::clearAnswer() { memset(m_answer, 0, m_nPixels*sizeof(Label)); } void ICM::setNeighbors(int pixel1, int pixel2, CostVal weight) { assert(!m_grid_graph); assert(pixel1 < m_nPixels && pixel1 >= 0 && pixel2 < m_nPixels && pixel2 >= 0); Neighbor *temp1 = (Neighbor *) new Neighbor; Neighbor *temp2 = (Neighbor *) new Neighbor; if ( !temp1 || ! temp2 ) {printf("\nNot enough memory, exiting");exit(0);} temp1->weight = weight; temp1->to_node = pixel2; temp2->weight = weight; temp2->to_node = pixel1; m_neighbors[pixel1].addFront(temp1); m_neighbors[pixel2].addFront(temp2); } MRF::EnergyVal ICM::smoothnessEnergy() { EnergyVal eng = (EnergyVal) 0; EnergyVal weight; int x,y,pix,i; if ( m_grid_graph ) { if ( m_smoothType != FUNCTION ) { for ( y = 0; y < m_height; y++ ) for ( x = 1; x < m_width; x++ ) { pix = x+y*m_width; weight = m_varWeights ? m_horizWeights[pix-1] : 1; eng = eng + m_V(m_answer[pix],m_answer[pix-1])*weight; } for ( y = 1; y < m_height; y++ ) for ( x = 0; x < m_width; x++ ) { pix = x+y*m_width; weight = m_varWeights ? m_vertWeights[pix-m_width] : 1; eng = eng + m_V(m_answer[pix],m_answer[pix-m_width])*weight; } } else { for ( y = 0; y < m_height; y++ ) for ( x = 1; x < m_width; x++ ) { pix = x+y*m_width; eng = eng + m_smoothFn(pix,pix-1,m_answer[pix],m_answer[pix-1]); } for ( y = 1; y < m_height; y++ ) for ( x = 0; x < m_width; x++ ) { pix = x+y*m_width; eng = eng + m_smoothFn(pix,pix-m_width,m_answer[pix],m_answer[pix-m_width]); } } } else { Neighbor *temp; if ( m_smoothType != FUNCTION ) { for ( i = 0; i < m_nPixels; i++ ) if ( !m_neighbors[i].isEmpty() ) { m_neighbors[i].setCursorFront(); while ( m_neighbors[i].hasNext() ) { temp = (Neighbor *) m_neighbors[i].next(); if ( i < temp->to_node ) eng = eng + m_V(m_answer[i],m_answer[temp->to_node])*(temp->weight); } } } else { for ( i = 0; i < m_nPixels; i++ ) if ( !m_neighbors[i].isEmpty() ) { m_neighbors[i].setCursorFront(); while ( m_neighbors[i].hasNext() ) { temp = (Neighbor *) m_neighbors[i].next(); if ( i < temp->to_node ) eng = eng + m_smoothFn(i,temp->to_node, m_answer[i],m_answer[temp->to_node]); } } } } return(eng); } MRF::EnergyVal ICM::dataEnergy() { EnergyVal eng = (EnergyVal) 0; if ( m_dataType == ARRAY) { for ( int i = 0; i < m_nPixels; i++ ) eng = eng + m_D(i,m_answer[i]); } else { for ( int i = 0; i < m_nPixels; i++ ) eng = eng + m_dataFn(i,m_answer[i]); } return(eng); } void ICM::setData(DataCostFn dcost) { m_dataFn = dcost; } void ICM::setData(CostVal* data) { m_D = data; } void ICM::setSmoothness(SmoothCostGeneralFn cost) { m_smoothFn = cost; } void ICM::setSmoothness(CostVal* V) { m_V = V; } void ICM::setSmoothness(int smoothExp,CostVal smoothMax, CostVal lambda) { int i, j; CostVal cost; m_needToFreeV = 1; m_V = (CostVal *) new CostVal[m_nLabels*m_nLabels*sizeof(CostVal)]; if (!m_V) { fprintf(stderr, "Not enough memory!\n"); exit(1); } for (i=0; i<m_nLabels; i++) for (j=i; j<m_nLabels; j++) { cost = (CostVal) ((smoothExp == 1) ? j - i : (j - i)*(j - i)); if (cost > smoothMax) cost = smoothMax; m_V[i*m_nLabels + j] = m_V[j*m_nLabels + i] = cost*lambda; } } void ICM::setCues(CostVal* hCue, CostVal* vCue) { m_horizWeights = hCue; m_vertWeights = vCue; } void ICM::optimizeAlg(int nIterations) { int x, y, i, j, n; Label* l; CostVal* dataPtr; CostVal *D = (CostVal *) new CostVal[m_nLabels]; if ( !D ) {printf("\nNot enough memory, exiting");exit(0);} if ( !m_grid_graph) {printf("\nICM is not implemented for nongrids yet!");exit(1);} for ( ; nIterations > 0; nIterations --) { n = 0; l = m_answer; dataPtr = m_D; for (y=0; y<m_height; y++) for (x=0; x<m_width; x++, l++, dataPtr+=m_nLabels, n++) { // set array D if (m_dataType == FUNCTION) { for (i=0; i<m_nLabels; i++) { D[i] = m_dataFn(x+y*m_width, i); } } else memcpy(D, dataPtr, m_nLabels*sizeof(CostVal)); // add smoothness costs if (m_smoothType == FUNCTION) { if (x > 0) { j = *(l-1); for (i=0; i<m_nLabels; i++) D[i] += m_smoothFn(x+y*m_width-1, x+y*m_width, j, i); } if (y > 0) { j = *(l-m_width); for (i=0; i<m_nLabels; i++) D[i] += m_smoothFn(x+y*m_width-m_width,x+y*m_width , j, i); } if (x < m_width-1) { j = *(l+1); for (i=0; i<m_nLabels; i++) D[i] += m_smoothFn(x+y*m_width+1, x+y*m_width, i, j); } if (y < m_height-1) { j = *(l+m_width); for (i=0; i<m_nLabels; i++) D[i] += m_smoothFn(x+y*m_width+m_width, x+y*m_width, i, j); } } else { if (x > 0) { j = *(l-1); CostVal lambda = (m_varWeights) ? m_horizWeights[n-1] : 1; for (i=0; i<m_nLabels; i++) D[i] += lambda * m_V[j*m_nLabels + i]; } if (y > 0) { j = *(l-m_width); CostVal lambda = (m_varWeights) ? m_vertWeights[n-m_width] : 1; for (i=0; i<m_nLabels; i++) D[i] += lambda * m_V[j*m_nLabels + i]; } if (x < m_width-1) { j = *(l+1); CostVal lambda = (m_varWeights) ? m_horizWeights[n] : 1; for (i=0; i<m_nLabels; i++) D[i] += lambda * m_V[j*m_nLabels + i]; } if (y < m_height-1) { j = *(l+m_width); CostVal lambda = (m_varWeights) ? m_vertWeights[n] : 1; for (i=0; i<m_nLabels; i++) D[i] += lambda * m_V[j*m_nLabels + i]; } } // compute minimum of D, set new label for (x,y) CostVal D_min = D[0]; *l = 0; for (i=1; i<m_nLabels; i++) { if (D_min > D[i]) { D_min = D[i]; *l = i; } } } } delete[] D; }
[ "hsy19891228@yeah.net" ]
hsy19891228@yeah.net
af81250867e38ca6f49aeba340c6102efb44fdf2
c502986e2904379c3b221506ea61ada9eac79b7b
/Valid Perfect Square.cpp
f7686f168d8f5345a2d56818341090be2ee87730
[]
no_license
hardik20sharma/LeetCode_Solutions
4d7252b4d134b9431b6c863cc3805eaa77d4c7c5
3ca4f52502764d76219b60e05b4180e29883e05d
refs/heads/master
2023-07-21T15:42:58.864998
2021-09-02T04:54:36
2021-09-02T04:54:36
287,471,908
0
0
null
null
null
null
UTF-8
C++
false
false
178
cpp
class Solution { public: bool isPerfectSquare(int num) { long long int n = 1; for( ; n * n < num; n++); return (n * n == num); } };
[ "noreply@github.com" ]
noreply@github.com
4ce36ba9639d891696b42fe4e24f23065117c1a0
73a8f3c9c640af08acbefe657bff62e3d1751fc2
/Dependencies/Qt-5.4.1/include/QtPlatformSupport/5.4.1/QtPlatformSupport/private/qevdevtouch_p.h
4bb68de5f4fd56f1856a74be94ffb6a81f4d915f
[]
no_license
knight666/pitstop
8d5ad076a71055803df1601e1df1640430ad56ca
4e541d90507f38f36274e50b0d702a284d648e27
refs/heads/master
2020-07-10T00:51:28.141786
2019-08-24T20:08:02
2019-08-24T20:08:02
204,123,196
0
0
null
null
null
null
UTF-8
C++
false
false
2,999
h
/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the plugins module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional ** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef QEVDEVTOUCH_P_H #define QEVDEVTOUCH_P_H // // W A R N I N G // ------------- // // This file is not part of the Qt API. It exists purely as an // implementation detail. This header file may change from version to // version without notice, or even be removed. // // We mean it. // #include <QObject> #include <QString> #include <QList> #include <QThread> #include <qpa/qwindowsysteminterface.h> #if !defined(QT_NO_MTDEV) struct mtdev; #endif QT_BEGIN_NAMESPACE class QSocketNotifier; class QEvdevTouchScreenData; class QEvdevTouchScreenHandler : public QObject { Q_OBJECT public: explicit QEvdevTouchScreenHandler(const QString &specification = QString(), QObject *parent = 0); ~QEvdevTouchScreenHandler(); private slots: void readData(); private: QSocketNotifier *m_notify; int m_fd; QEvdevTouchScreenData *d; #if !defined(QT_NO_MTDEV) mtdev *m_mtdev; #endif }; class QEvdevTouchScreenHandlerThread : public QThread { public: explicit QEvdevTouchScreenHandlerThread(const QString &spec, QObject *parent = 0); ~QEvdevTouchScreenHandlerThread(); void run(); QEvdevTouchScreenHandler *handler() { return m_handler; } private: QString m_spec; QEvdevTouchScreenHandler *m_handler; }; QT_END_NAMESPACE #endif // QEVDEVTOUCH_P_H
[ "knight666+github@gmail.com" ]
knight666+github@gmail.com
015e68ccd49fe98db355e62112dc25533fcf1aec
6cecdbbe6eb721a0e43c07ed2b31bdcc9e553c55
/Sail2D/Runs/first_flatplate_150_12/case/1000/nuTilda
7e099e7339135e879aa7eb1d799540690c1f2f2d
[]
no_license
kiranhegde/Gmsh
799d8cbefb7dd3f3d35ded15b40292fd3ede6468
fefa906dabfddd9b87cc1f0256df81b4735420e1
refs/heads/master
2021-01-19T23:21:57.414954
2015-01-21T02:02:37
2015-01-21T02:02:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
149,412
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 2.3.0 | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "1000"; object nuTilda; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 2 -1 0 0 0 0]; internalField nonuniform List<scalar> 14757 ( 0.0535668 0.0503004 0.0471382 0.0441086 0.0412386 0.0385552 0.0360856 0.0338609 0.0318811 0.0299921 0.02815 0.0263847 0.0247086 0.0231203 0.0216118 0.0201736 0.0187966 0.0174732 0.0161984 0.0149682 0.0137778 0.0126249 0.0115339 0.0107361 0.0575158 0.0548062 0.0521866 0.049666 0.0472506 0.0449445 0.0427526 0.0406799 0.0387299 0.0368992 0.0351867 0.0335965 0.0321347 0.030807 0.0296196 0.0285781 0.0276873 0.0269541 0.0263829 0.0259774 0.0257419 0.0256759 0.0257802 0.0260501 0.0610485 0.0587913 0.0566167 0.0545293 0.052531 0.0506247 0.0488124 0.0470969 0.0454816 0.0439682 0.0425604 0.0412612 0.0400752 0.0390066 0.0380604 0.0372412 0.0365537 0.0360024 0.0355901 0.0353177 0.0351867 0.0351947 0.0353359 0.0356018 0.0641892 0.062299 0.0604823 0.0587398 0.0570726 0.0554816 0.0539683 0.0525347 0.0511836 0.0499167 0.0487376 0.0476496 0.0466568 0.0457627 0.0449722 0.044289 0.0437176 0.0432621 0.0429251 0.0427082 0.0426121 0.0426361 0.042776 0.0430267 0.0669743 0.0653783 0.0638478 0.0623792 0.0609716 0.0596258 0.0583427 0.0571239 0.0559721 0.054889 0.053878 0.0529424 0.0520862 0.0513137 0.0506284 0.0500355 0.0495395 0.0491437 0.0488522 0.0486668 0.0485893 0.0486194 0.048755 0.0489926 0.0694261 0.0680753 0.0667764 0.0655258 0.0643231 0.0631686 0.0620635 0.0610101 0.0600103 0.0590662 0.0581813 0.0573588 0.0566028 0.0559177 0.0553078 0.0547781 0.0543333 0.053978 0.0537158 0.0535499 0.0534825 0.0535145 0.0536447 0.0538709 0.0715902 0.0704384 0.0693259 0.0682506 0.0672112 0.0662076 0.0652421 0.0643169 0.0634351 0.0625984 0.0618101 0.0610736 0.0603932 0.0597735 0.0592192 0.058736 0.0583286 0.0580014 0.0577594 0.0576063 0.0575453 0.0575773 0.0577025 0.0579192 0.0734988 0.0725106 0.0715484 0.070615 0.0697074 0.0688255 0.0679705 0.0671459 0.0663568 0.0656047 0.0648926 0.0642233 0.0636016 0.0630329 0.0625209 0.0620724 0.0616933 0.0613874 0.061159 0.0610147 0.0609574 0.060989 0.0611099 0.0613189 0.0751809 0.0743303 0.073487 0.0726687 0.07187 0.0710871 0.070323 0.0695759 0.06886 0.0681765 0.0675267 0.0669125 0.0663368 0.0658114 0.0653325 0.06491 0.0645517 0.0642653 0.064045 0.0639064 0.0638506 0.0638809 0.0639989 0.0642024 0.0766803 0.0759424 0.0751786 0.0744535 0.0737491 0.0730441 0.0723637 0.0716697 0.0710079 0.0703772 0.0697769 0.0692162 0.0686741 0.0681952 0.0677421 0.067342 0.0669902 0.0667331 0.0665154 0.0663814 0.0663244 0.0663512 0.0664665 0.0666678 0.0118147 0.0140883 0.0156227 0.0171284 0.018764 0.0205598 0.0225122 0.0246116 0.0268444 0.0291983 0.0316625 0.034228 0.0368871 0.0396339 0.0424619 0.0453649 0.0483365 0.0513703 0.054459 0.0575947 0.0607697 0.0639754 0.0672038 0.0704636 0.0264685 0.027048 0.0278124 0.0287639 0.0298992 0.0312105 0.0326877 0.0343185 0.0360885 0.0379848 0.0399957 0.042109 0.0443149 0.0466046 0.04897 0.051404 0.0539006 0.0564536 0.059057 0.0617055 0.0643932 0.0671143 0.069864 0.0726541 0.0359812 0.036486 0.037135 0.0379306 0.038871 0.0399513 0.0411665 0.042508 0.0439664 0.0455323 0.0471975 0.0489529 0.0507901 0.0527022 0.0546821 0.0567237 0.0588219 0.0609717 0.0631681 0.0654072 0.0676842 0.0699951 0.0723372 0.074725 0.0433805 0.043845 0.0444308 0.0451385 0.0459666 0.0469107 0.0479662 0.0491262 0.0503828 0.0517288 0.0531571 0.0546599 0.0562309 0.0578644 0.0595543 0.0612956 0.063084 0.0649156 0.0667865 0.0686939 0.0706346 0.0726056 0.0746047 0.0766415 0.0493275 0.0497636 0.0503066 0.0509561 0.0517098 0.0525628 0.0535099 0.0545444 0.0556598 0.0568495 0.058107 0.0594253 0.0607993 0.0622236 0.0636932 0.0652041 0.0667518 0.0683334 0.069946 0.0715873 0.0732555 0.0749489 0.076666 0.0784146 0.05419 0.0546038 0.0551151 0.0557223 0.056422 0.0572092 0.0580775 0.0590206 0.0600322 0.0611063 0.0622362 0.0634163 0.0646416 0.0659071 0.0672083 0.0685411 0.0699015 0.0712867 0.0726943 0.0741228 0.0755709 0.0770378 0.0785235 0.0800367 0.0582252 0.0586211 0.0591077 0.0596826 0.0603417 0.0610788 0.0618871 0.0627602 0.0636921 0.0646766 0.0657082 0.0667815 0.0678918 0.0690345 0.0702049 0.0713985 0.0726111 0.0738403 0.0750839 0.0763409 0.0776105 0.0788919 0.0801857 0.0814996 0.0616141 0.061995 0.0624613 0.0630109 0.0636388 0.0643376 0.065099 0.0659158 0.0667829 0.0676959 0.06865 0.0696385 0.0706578 0.0717041 0.0727718 0.0738552 0.0749499 0.0760534 0.0771643 0.078282 0.0794059 0.0805346 0.0816682 0.0828107 0.0644881 0.0648566 0.065305 0.0658336 0.0664385 0.0671084 0.0678327 0.068601 0.0694136 0.0702681 0.0711623 0.0720792 0.073025 0.0739959 0.0749836 0.0759779 0.0769769 0.0779769 0.078979 0.0799831 0.0809879 0.0819896 0.0829896 0.0839873 0.0669421 0.0673015 0.0677311 0.0682418 0.0688319 0.0694748 0.0701679 0.0708943 0.0716649 0.0724724 0.0733276 0.0741698 0.0750578 0.0759735 0.0768997 0.0778181 0.0787417 0.0796521 0.0805639 0.0814763 0.082387 0.0832806 0.0841739 0.0850406 0.0609934 0.0551988 0.0498779 0.0450153 0.0405852 0.0365589 0.0329079 0.0296064 0.0266307 0.0239508 0.0215345 0.019351 0.0173732 0.0155774 0.0139387 0.0124295 0.0110409 0.00980271 0.00879142 0.00793082 0.0070622 0.00610434 0.00499638 0.00363414 0.0612378 0.0559817 0.0511643 0.0467491 0.0427089 0.0390217 0.03567 0.0326416 0.0299219 0.0274879 0.0253198 0.0234008 0.0217159 0.0202574 0.0190431 0.0179564 0.0168738 0.0157437 0.0145462 0.013269 0.0118871 0.0103617 0.0086409 0.00665002 0.0614757 0.0567648 0.0524182 0.0484123 0.0447289 0.0413543 0.0382812 0.0355098 0.0330278 0.0308263 0.0289003 0.0272501 0.0258866 0.0247092 0.0235725 0.0224224 0.0212246 0.0199499 0.0185709 0.0170583 0.0153806 0.0135017 0.011379 0.00896638 0.061773 0.0575462 0.0536227 0.0499849 0.0466213 0.043526 0.0407009 0.0381496 0.0358682 0.0338585 0.0321292 0.0306968 0.0294751 0.0283048 0.0271241 0.0258961 0.024591 0.0231819 0.021641 0.0199367 0.0180348 0.015896 0.0134793 0.0107424 0.0620946 0.0583153 0.054772 0.0514609 0.0483797 0.0455295 0.0429183 0.0405518 0.0384336 0.0365733 0.0349864 0.0336812 0.0324714 0.0312703 0.0300337 0.0287295 0.027329 0.0258045 0.0241255 0.022259 0.0201687 0.0178137 0.01515 0.0121324 0.0625117 0.0590935 0.0558734 0.0528457 0.0500103 0.0473719 0.0449435 0.0427317 0.040746 0.0390026 0.0375245 0.0362525 0.0350273 0.0337872 0.0324952 0.0311205 0.0296344 0.0280073 0.0262072 0.0241993 0.0219447 0.0193998 0.0165168 0.0132479 0.0629597 0.0598644 0.056927 0.0541457 0.0515236 0.0490689 0.0467958 0.0447134 0.0428353 0.0411812 0.0397784 0.0385072 0.0372563 0.0359751 0.0346296 0.0331891 0.0316237 0.0299033 0.027994 0.0258586 0.0234561 0.0207398 0.0176586 0.0141609 0.063447 0.0606284 0.057936 0.0553688 0.0529324 0.0506372 0.0484971 0.0465246 0.044736 0.0431508 0.0417924 0.040514 0.0392352 0.0379135 0.0365164 0.035013 0.0333736 0.0315667 0.0295564 0.0273035 0.0247654 0.0218919 0.0186287 0.0149215 0.0639558 0.0613825 0.0589044 0.0565236 0.0542502 0.052094 0.0500693 0.0481919 0.0464816 0.0449569 0.0436195 0.0423269 0.0410199 0.039658 0.0382105 0.0366462 0.034936 0.033049 0.0309466 0.0285831 0.0259203 0.0228994 0.0194635 0.0155596 0.0644917 0.0621295 0.0598393 0.0576184 0.0554901 0.0534569 0.051534 0.0497369 0.0480967 0.046636 0.0453 0.0439862 0.0426535 0.0412492 0.0397528 0.0381275 0.0363466 0.0343849 0.0322084 0.0297361 0.0269603 0.0238013 0.0201939 0.0160791 0.00200123 0.000994953 0.00108462 0.00137248 0.00165194 0.00192941 0.00221935 0.00254402 0.00293675 0.00344244 0.00406926 0.00479785 0.00562596 0.00655738 0.00759782 0.00875338 0.0100306 0.0114366 0.0129806 0.0146725 0.0165223 0.0185414 0.02074 0.0231203 0.00431995 0.00215075 0.00145814 0.00166589 0.0019617 0.00227532 0.00262612 0.00303904 0.00353774 0.00414294 0.00484838 0.00563849 0.00651384 0.00747833 0.00853654 0.00969243 0.0109516 0.0123209 0.0138077 0.0154205 0.0171678 0.0190585 0.0211007 0.0233025 0.00621106 0.00337501 0.00190495 0.00195126 0.00227896 0.00265388 0.00308747 0.0035959 0.00418881 0.00487917 0.00564958 0.00649182 0.00740734 0.00839896 0.00946898 0.0106211 0.0118599 0.0131911 0.0146207 0.0161555 0.0178026 0.0195686 0.0214605 0.0234855 0.00763662 0.00437674 0.00235382 0.00223135 0.00260452 0.00305441 0.00357477 0.00417069 0.00484446 0.00560421 0.00642904 0.00731535 0.00826415 0.00927648 0.0103539 0.0114996 0.0127172 0.0140112 0.0153862 0.0168475 0.0184004 0.0200502 0.0218008 0.0236526 0.00871872 0.00513509 0.00275446 0.00250846 0.00293684 0.00346442 0.00406535 0.00473708 0.00548162 0.00629839 0.00716986 0.00809367 0.00906971 0.0100981 0.0111802 0.0123181 0.0135146 0.0147731 0.016097 0.0174902 0.0189563 0.0204994 0.0221241 0.0238405 0.00955676 0.0057042 0.00309526 0.00278198 0.00327017 0.00387124 0.00454282 0.00527917 0.00608725 0.0069526 0.00786455 0.00882054 0.00981928 0.0108606 0.0119453 0.0130749 0.0142513 0.0154765 0.0167531 0.0180835 0.0194705 0.0209178 0.02243 0.024015 0.0102191 0.00613747 0.00338311 0.00304888 0.00359746 0.00426526 0.00499936 0.00579448 0.00665568 0.00756369 0.00851101 0.00949431 0.0105121 0.011564 0.0126502 0.0137715 0.0149285 0.0161228 0.0173558 0.0186292 0.019945 0.021306 0.0227169 0.0241848 0.0107532 0.00647548 0.00362922 0.00330799 0.00391492 0.00464183 0.0054305 0.00627896 0.00718517 0.0081304 0.00910818 0.0101151 0.0111495 0.0122103 0.0132972 0.0144102 0.0155493 0.0167152 0.0179086 0.0191301 0.0203812 0.021664 0.0229814 0.0243343 0.0111861 0.00675217 0.00385287 0.00354746 0.00420467 0.00498483 0.00582353 0.00672319 0.00767035 0.00865008 0.00965647 0.010686 0.011736 0.0128051 0.0138915 0.0149956 0.0161179 0.0172581 0.0184152 0.0195893 0.0207804 0.0219908 0.0232224 0.0244756 0.0114537 0.00681743 0.00395725 0.00381114 0.00455468 0.00538628 0.00626689 0.00720714 0.00818687 0.0091982 0.0102302 0.0112739 0.0123277 0.0133882 0.0144541 0.0155399 0.0166478 0.017766 0.0188859 0.0200117 0.0211377 0.022276 0.0234318 0.0246139 0.000406078 0.00136636 0.00289458 0.00468958 0.00649389 0.00828252 0.0100832 0.0118971 0.0137237 0.0155651 0.017426 0.0193128 0.0212351 0.0232022 0.0252193 0.0272853 0.0294187 0.0316848 0.0341109 0.0366409 0.0394977 0.0426869 0.0461138 0.0497035 0.000316198 0.000803013 0.0018602 0.00332355 0.00496536 0.00659941 0.0082134 0.00982644 0.0114605 0.0131357 0.0148568 0.016628 0.0184538 0.0203402 0.0222933 0.0243201 0.0264317 0.0286537 0.0310145 0.0335227 0.0362736 0.0392956 0.0425349 0.0461478 0.000162619 0.000494581 0.00116649 0.00212947 0.0033971 0.00499411 0.00691798 0.00880507 0.0106222 0.0123798 0.014099 0.0157989 0.0174971 0.0192127 0.0209669 0.0227827 0.0246851 0.0267019 0.0288663 0.0312132 0.033794 0.0366495 0.0397758 0.0432029 0.00017961 0.000414399 0.000958027 0.00172958 0.00275187 0.00405622 0.00568179 0.00762579 0.00962038 0.0115866 0.0135114 0.0153853 0.0172017 0.018961 0.020674 0.022364 0.0240666 0.0258279 0.0277028 0.0297529 0.0320422 0.0346297 0.0375488 0.0408128 0.000150515 0.000361743 0.000828804 0.00148875 0.00237086 0.00349442 0.00489244 0.00660339 0.00862948 0.01073 0.0128138 0.014862 0.0168627 0.0187995 0.0206564 0.0224253 0.0241152 0.0257579 0.0274107 0.0291548 0.0310859 0.0333026 0.0358869 0.0388978 0.000148709 0.000336677 0.000752111 0.00134155 0.00213195 0.00313916 0.00439313 0.00593034 0.00779152 0.00990598 0.0120819 0.0142546 0.0164032 0.0185098 0.0205514 0.0225006 0.0243346 0.0260467 0.0276587 0.0292318 0.0308678 0.0326987 0.0348628 0.0374731 0.000144939 0.000328977 0.000697782 0.00123862 0.00196276 0.00288812 0.00403919 0.00544885 0.00715595 0.00918629 0.0113936 0.0136469 0.0159015 0.018137 0.0203316 0.0224569 0.0244782 0.0263624 0.0280899 0.0296737 0.0311778 0.0327253 0.034487 0.0366567 0.000146664 0.000328866 0.000661806 0.0011683 0.00184508 0.00271157 0.00378838 0.00510584 0.00670064 0.00861163 0.0107897 0.0130798 0.0154052 0.017735 0.0200475 0.0223163 0.0245073 0.0265791 0.0284896 0.0302107 0.0317515 0.0331844 0.0346626 0.0364229 0.000148455 0.00033105 0.000636333 0.00111787 0.00176031 0.00258403 0.00360616 0.00485475 0.00636426 0.00817388 0.0102882 0.0125806 0.0149483 0.0173448 0.0197455 0.0221262 0.0244555 0.026693 0.0287901 0.0306977 0.0323827 0.0338577 0.0352184 0.0366854 0.000151361 0.000333127 0.000619365 0.00108311 0.00170093 0.00249365 0.00347568 0.00467321 0.00611885 0.00785049 0.00989276 0.0121631 0.0145498 0.0169917 0.0194577 0.0219242 0.024363 0.0267373 0.0289994 0.0310933 0.0329645 0.0345806 0.0359716 0.0372911 0.000154823 0.000335723 0.000608415 0.0010596 0.00166 0.00243065 0.00338371 0.00454372 0.00594166 0.00761394 0.00959232 0.0118297 0.0142198 0.0166913 0.0192059 0.0217386 0.0242637 0.0267481 0.0291481 0.0314083 0.0334663 0.0352648 0.0367826 0.0380957 0.000158925 0.000338722 0.000602386 0.00104493 0.00163345 0.0023888 0.00332146 0.00445455 0.00581761 0.00744569 0.00937297 0.0115761 0.013961 0.0164518 0.0190036 0.0215885 0.0241824 0.0267556 0.0292687 0.0316701 0.0338971 0.0358818 0.0375703 0.038967 0.000163463 0.000342198 0.000600242 0.00103704 0.00161813 0.00236319 0.00328212 0.00439664 0.00573506 0.00733115 0.00921988 0.0113931 0.0137705 0.0162753 0.0188576 0.0214863 0.024137 0.026783 0.0293889 0.0319082 0.034281 0.0364371 0.0383056 0.039842 0.000168339 0.000346015 0.000601045 0.00103423 0.00161125 0.00235006 0.0032605 0.00436303 0.00568493 0.00725889 0.00911998 0.0112702 0.0136419 0.0161595 0.0187697 0.0214376 0.0241383 0.0268466 0.0295306 0.0321482 0.0346447 0.0369514 0.038991 0.0406939 0.000173429 0.000350029 0.000603819 0.00103507 0.00161047 0.00234632 0.00325233 0.00434801 0.00565979 0.00721947 0.00906193 0.0111964 0.0135664 0.0160985 0.0187368 0.0214433 0.024191 0.0269557 0.029708 0.0324097 0.035011 0.0374473 0.0396402 0.0415053 0.000178649 0.000354108 0.000607898 0.00103866 0.00161431 0.00234971 0.00325441 0.00434717 0.00565375 0.00720523 0.00903631 0.0111617 0.0135346 0.0160844 0.0187531 0.0214998 0.024295 0.027114 0.0299295 0.0327062 0.0353984 0.0379464 0.0402739 0.0422904 0.000183938 0.000358171 0.000612797 0.00104431 0.00162162 0.00235846 0.00326414 0.00435696 0.0056621 0.00721003 0.00903529 0.0111569 0.0135372 0.0161084 0.0188109 0.0216007 0.0244457 0.0273199 0.030197 0.0330439 0.0358181 0.0384645 0.0409106 0.0430662 0.000189219 0.000362131 0.000618153 0.00105141 0.0016314 0.00237113 0.00327952 0.00437454 0.00568106 0.00722895 0.0090526 0.0111747 0.0135659 0.0161618 0.0189015 0.0217379 0.0246359 0.0275679 0.0305073 0.0334228 0.036274 0.0390097 0.0415614 0.0438421 0.00019443 0.000365965 0.000623706 0.00105954 0.00164303 0.00238655 0.00329892 0.00439773 0.00570762 0.00725807 0.00908326 0.0112089 0.0136136 0.0162368 0.0190166 0.0219029 0.0248575 0.0278506 0.0308548 0.0338392 0.0367657 0.0395853 0.0422341 0.0446283 0.000199542 0.000369646 0.000629328 0.00106832 0.00165584 0.00240385 0.00332104 0.00442484 0.00573949 0.00729435 0.00912336 0.0112546 0.0136746 0.0163268 0.0191489 0.0220878 0.0251022 0.0281597 0.0312315 0.0342868 0.0372887 0.0401903 0.0429312 0.0454324 0.000204548 0.00037316 0.000634923 0.00107746 0.00166931 0.00242233 0.00334492 0.00445437 0.0057749 0.00733546 0.00916993 0.0113084 0.0137444 0.0164266 0.0192922 0.0222859 0.0253626 0.0284872 0.0316294 0.0347577 0.0378357 0.0408177 0.0436461 0.0462449 0.000209433 0.000376522 0.000640491 0.00108684 0.00168324 0.0024415 0.00336988 0.00448552 0.0058125 0.00737967 0.00922069 0.0113673 0.0138197 0.016532 0.0194419 0.0224915 0.0256327 0.0288269 0.0320418 0.035245 0.0383999 0.0414611 0.0443719 0.0470586 0.000214166 0.000379698 0.000645883 0.00109619 0.00169723 0.00246086 0.00339518 0.00451735 0.00585119 0.00742552 0.00927388 0.0114292 0.0138979 0.01664 0.0195943 0.0227006 0.0259075 0.0291735 0.0324633 0.0357434 0.0389764 0.0421169 0.0451081 0.0478757 0.000218738 0.000382699 0.000651103 0.00110541 0.00171111 0.00248011 0.00342041 0.00454916 0.00589012 0.00747195 0.00932807 0.0114925 0.013977 0.0167482 0.0197464 0.0229097 0.0261837 0.0295231 0.0328903 0.0362499 0.0395639 0.0427871 0.045864 0.0487272 0.000223141 0.000385524 0.000656103 0.00111436 0.00172462 0.00249894 0.00344517 0.00458047 0.00592854 0.00751797 0.00938206 0.0115556 0.0140554 0.0168545 0.0198957 0.023116 0.0264576 0.029872 0.0333187 0.0367603 0.0401578 0.0434656 0.0466283 0.0495774 0.000227387 0.000388192 0.000660933 0.00112305 0.00173771 0.0025172 0.00346921 0.0046109 0.00596597 0.00756289 0.00943491 0.0116175 0.0141316 0.0169572 0.0200401 0.0233166 0.0267261 0.0302166 0.0337444 0.0372703 0.0407537 0.0441485 0.0473984 0.050434 0.000231453 0.000390685 0.000665517 0.00113136 0.00175026 0.00253475 0.0034923 0.00464015 0.00600196 0.00760615 0.00948589 0.0116772 0.0142045 0.0170547 0.0201777 0.0235091 0.0269861 0.0305532 0.0341636 0.0377757 0.0413475 0.0448321 0.0481727 0.0512993 0.000235349 0.000393016 0.000669848 0.00113925 0.00176221 0.00255144 0.00351423 0.00466793 0.00603619 0.00764734 0.00953444 0.0117339 0.0142733 0.0171461 0.0203068 0.0236914 0.0272349 0.0308786 0.0345724 0.0382722 0.0419348 0.0455125 0.0489484 0.0521729 0.000239068 0.000395191 0.000673926 0.00114671 0.0017735 0.00256721 0.00353496 0.00469415 0.00606843 0.0076861 0.00958014 0.0117872 0.0143375 0.0172307 0.0204263 0.0238619 0.0274702 0.0311897 0.0349669 0.0387552 0.04251 0.0461828 0.0497172 0.0530458 0.000242637 0.000397218 0.000677771 0.00115374 0.00178412 0.00258204 0.00355444 0.00471875 0.00609863 0.00772236 0.00962284 0.0118369 0.0143968 0.017308 0.0205358 0.0240194 0.0276904 0.0314841 0.0353439 0.0392207 0.0430679 0.0468363 0.0504688 0.053898 0.000246052 0.000399119 0.000681415 0.00116037 0.00179411 0.00259597 0.00357269 0.00474175 0.00612681 0.00775609 0.00966244 0.0118828 0.0144512 0.0173782 0.0206351 0.0241635 0.0278944 0.0317603 0.0357013 0.0396655 0.0436045 0.0474678 0.0511972 0.0547222 0.000249296 0.000400884 0.000684798 0.00116657 0.00180344 0.00260898 0.00358968 0.00476315 0.00615299 0.00778737 0.00969907 0.0119251 0.0145009 0.0174417 0.0207247 0.0242946 0.0280823 0.0320178 0.0360379 0.0400879 0.0441175 0.0480751 0.0519026 0.0555323 0.000252398 0.000402532 0.000687959 0.00117235 0.00181218 0.00262113 0.0036055 0.004783 0.00617724 0.00781632 0.00973287 0.011964 0.0145462 0.0174989 0.0208052 0.0244135 0.0282548 0.0322571 0.0363541 0.040488 0.0446062 0.0486556 0.0525771 0.0562998 0.000255354 0.000404066 0.000690903 0.00117776 0.00182033 0.00263246 0.00362024 0.00480144 0.00619967 0.00784299 0.00976398 0.0119996 0.0145875 0.0175505 0.0208775 0.0245211 0.028413 0.0324795 0.0366511 0.0408671 0.0450722 0.0492117 0.0532244 0.0570377 0.000258178 0.000405495 0.000693664 0.00118286 0.00182799 0.00264308 0.00363401 0.00481861 0.00622047 0.00786764 0.00979257 0.0120323 0.014625 0.017597 0.0209423 0.0246183 0.028558 0.0326861 0.0369306 0.0412272 0.0455185 0.0497478 0.0538534 0.0577616 0.000260874 0.000406825 0.000696253 0.00118765 0.00183519 0.00265306 0.00364691 0.00483461 0.0062398 0.00789043 0.00981892 0.0120623 0.0146592 0.0176387 0.0210003 0.0247059 0.0286906 0.0328779 0.0371933 0.0415695 0.0459466 0.0502667 0.0544672 0.0584759 0.00026345 0.000408063 0.000698683 0.00119216 0.00184196 0.00266243 0.00365898 0.00484959 0.00625785 0.00791161 0.00984328 0.0120898 0.0146903 0.0176762 0.021052 0.0247845 0.0288111 0.0330552 0.0374394 0.0418938 0.046356 0.0507665 0.0550624 0.0591716 0.000265907 0.000409215 0.000700961 0.00119642 0.00184836 0.00267128 0.00367035 0.00486363 0.00627468 0.00793136 0.00986592 0.0121152 0.0147188 0.0177101 0.021098 0.0248548 0.0289205 0.0332183 0.0376689 0.0421996 0.0467454 0.0512455 0.0556362 0.0598453 0.000268253 0.000410281 0.000703111 0.00120047 0.00185443 0.00267967 0.0036811 0.00487688 0.00629053 0.00794985 0.00988701 0.0121388 0.014745 0.0177408 0.0211394 0.0249179 0.0290197 0.0333682 0.0378825 0.0424868 0.0471138 0.051701 0.0561843 0.060492 0.000270498 0.000411268 0.000705134 0.00120432 0.0018602 0.00268762 0.00369128 0.0048894 0.0063055 0.00796727 0.00990685 0.0121609 0.0147695 0.0177692 0.0211771 0.0249752 0.0291103 0.0335067 0.0380818 0.0427571 0.0474625 0.0521335 0.0567046 0.0611027 0.000272647 0.000412171 0.00070703 0.00120797 0.0018657 0.00269517 0.00370092 0.00490125 0.00631964 0.00798375 0.00992559 0.0121818 0.0147925 0.0177956 0.0212117 0.0250277 0.029194 0.0336358 0.0382691 0.043013 0.0477947 0.0525473 0.0572037 0.0616872 0.0002747 0.000412995 0.000708795 0.00121144 0.00187096 0.00270232 0.00371005 0.00491245 0.00633302 0.00799935 0.00994335 0.0122016 0.0148143 0.0178205 0.0212439 0.0250763 0.0292719 0.0337571 0.0384468 0.0432576 0.048114 0.0529474 0.0576897 0.0622658 0.000276658 0.000413727 0.000710449 0.00121473 0.00187601 0.00270911 0.00371869 0.00492307 0.00634568 0.0080141 0.00996016 0.0122203 0.0148349 0.0178439 0.021274 0.0251216 0.0293449 0.0338719 0.0386164 0.0434928 0.0484228 0.0533364 0.0581653 0.0628375 0.000278523 0.00041437 0.000711994 0.00121784 0.00188079 0.00271553 0.00372684 0.00493307 0.00635761 0.00802799 0.00997599 0.0122379 0.0148544 0.0178659 0.0213021 0.0251638 0.0294134 0.0339806 0.0387787 0.0437193 0.0487216 0.0537133 0.0586249 0.0633826 0.000280312 0.000414914 0.00071344 0.00122077 0.0018853 0.00272156 0.0037345 0.00494243 0.00636878 0.00804099 0.00999079 0.0122545 0.0148725 0.0178864 0.0213281 0.0252028 0.0294774 0.0340837 0.0389342 0.0439383 0.0490125 0.0540817 0.059075 0.063919 0.000282012 0.000415374 0.000714777 0.0012235 0.00188953 0.0027272 0.00374161 0.00495111 0.00637909 0.00805298 0.0100044 0.0122696 0.0148892 0.0179051 0.0213517 0.0252384 0.0295367 0.0341807 0.0390827 0.0441497 0.0492957 0.0544432 0.0595189 0.0644442 0.000283604 0.000415738 0.00071601 0.00122605 0.00189349 0.00273244 0.00374818 0.00495908 0.00638851 0.00806387 0.0100168 0.0122833 0.0149041 0.0179217 0.0213725 0.0252701 0.0295905 0.0342709 0.0392231 0.0443524 0.0495701 0.0547966 0.0599586 0.0649807 0.00028511 0.000416011 0.00071716 0.00122844 0.00189718 0.00273728 0.00375419 0.0049663 0.00639697 0.00807357 0.0100277 0.0122953 0.014917 0.017936 0.0213902 0.0252975 0.0296384 0.0343532 0.0393542 0.0445444 0.0498325 0.055137 0.060384 0.0655002 0.000286566 0.000416204 0.000718271 0.0012307 0.00190063 0.00274174 0.00375964 0.00497276 0.00640443 0.00808202 0.010037 0.0123054 0.0149278 0.0179476 0.0214046 0.0253202 0.02968 0.0344275 0.0394754 0.0447249 0.0500814 0.055461 0.0607883 0.0659923 0.000287927 0.000416311 0.000719294 0.00123279 0.00190381 0.00274582 0.00376455 0.00497846 0.00641089 0.00808915 0.0100447 0.0123135 0.014936 0.0179562 0.0214151 0.0253377 0.0297147 0.0344931 0.0395865 0.044894 0.0503179 0.0557705 0.0611728 0.066446 0.000289173 0.00041635 0.000720247 0.00123476 0.00190682 0.0027496 0.003769 0.00498351 0.00641643 0.00809505 0.0100508 0.0123195 0.0149417 0.0179616 0.0214215 0.0253497 0.0297418 0.0345493 0.0396866 0.0450512 0.0505424 0.0560694 0.061551 0.0669064 0.000290334 0.0004163 0.000721166 0.00123664 0.00190966 0.0027531 0.00377304 0.00498797 0.00642116 0.00809984 0.0100554 0.0123236 0.0149449 0.0179637 0.0214236 0.0253557 0.0297608 0.0345948 0.039774 0.0451947 0.0507529 0.056355 0.0619173 0.0673595 0.00029145 0.000416165 0.000722103 0.00123849 0.00191241 0.00275643 0.00377681 0.00499198 0.00642523 0.00810373 0.0100587 0.0123259 0.0149458 0.0179628 0.0214215 0.0253557 0.0297712 0.0346288 0.0398473 0.0453219 0.050946 0.0566228 0.0622673 0.0677991 0.000292477 0.000415966 0.000723012 0.0012403 0.00191504 0.00275955 0.00378031 0.00499562 0.00642874 0.00810685 0.010061 0.0123267 0.0149448 0.0179594 0.0214157 0.0253503 0.0297735 0.0346513 0.0399055 0.0454309 0.0511186 0.0568685 0.0625934 0.0682128 0.000293386 0.00041572 0.000723886 0.00124203 0.00191761 0.00276264 0.00378369 0.00499907 0.00643195 0.00810947 0.0100625 0.0123267 0.0149423 0.0179539 0.021407 0.0253405 0.0297688 0.0346633 0.0399492 0.0455216 0.0512689 0.0570883 0.0628891 0.0685865 0.000294198 0.000415423 0.000724705 0.00124367 0.0019201 0.00276559 0.00378687 0.00500226 0.00643489 0.00811176 0.0100636 0.0123259 0.014939 0.0179471 0.0213965 0.0253276 0.0297588 0.0346669 0.0399807 0.0455959 0.0513991 0.0572844 0.0631585 0.0689352 0.00029494 0.000415055 0.000725481 0.00124523 0.00192251 0.00276844 0.00378995 0.00500533 0.00643764 0.00811379 0.0100644 0.0123249 0.0149351 0.0179396 0.0213849 0.0253128 0.0297454 0.0346645 0.0400029 0.0456572 0.0515124 0.05746 0.0634045 0.0692595 0.00029562 0.000414645 0.000726263 0.00124679 0.00192485 0.00277118 0.00379292 0.00500829 0.00644027 0.0081157 0.0100651 0.0123236 0.0149311 0.0179319 0.0213728 0.0252971 0.0297301 0.0346582 0.0400184 0.0457087 0.0516126 0.0576189 0.0636298 0.0695581 0.000296217 0.000414146 0.000727003 0.00124829 0.00192711 0.00277388 0.00379585 0.00501118 0.00644285 0.00811757 0.0100658 0.0123224 0.0149272 0.0179242 0.0213608 0.0252811 0.0297135 0.0346492 0.0400292 0.045753 0.0517028 0.0577649 0.0638386 0.0698322 0.000296721 0.000413605 0.000727674 0.00124968 0.00192927 0.00277643 0.00379859 0.00501395 0.00644535 0.00811941 0.0100664 0.0123212 0.0149234 0.0179168 0.021349 0.0252652 0.0296965 0.0346385 0.0400365 0.0457917 0.0517855 0.0579022 0.0640399 0.0701109 0.000297146 0.000412994 0.000728275 0.00125097 0.0019313 0.00277883 0.00380115 0.00501649 0.00644762 0.00812108 0.010067 0.0123201 0.0149197 0.0179096 0.0213375 0.0252496 0.0296793 0.0346265 0.0400408 0.0458252 0.0518604 0.0580281 0.0642238 0.0703559 0.000297503 0.000412314 0.000728784 0.00125212 0.00193313 0.00278097 0.00380345 0.00501876 0.00644961 0.00812247 0.0100674 0.0123189 0.0149161 0.0179027 0.0213265 0.0252345 0.0296623 0.034614 0.0400433 0.0458552 0.0519293 0.0581452 0.0643956 0.0705866 0.000297791 0.000411555 0.00072926 0.00125319 0.00193482 0.00278291 0.0038055 0.00502072 0.00645126 0.00812348 0.0100674 0.0123173 0.0149122 0.0178958 0.0213156 0.0252196 0.0296455 0.0346013 0.0400448 0.045883 0.0519948 0.058257 0.0645597 0.0708062 0.000297986 0.000410731 0.00072964 0.00125411 0.0019363 0.0027846 0.00380721 0.00502227 0.00645242 0.00812394 0.0100668 0.0123151 0.0149078 0.0178883 0.0213044 0.0252045 0.0296284 0.034588 0.0400453 0.0459094 0.0520585 0.058367 0.0647223 0.0710251 0.000298097 0.000409833 0.000729911 0.00125486 0.00193755 0.00278595 0.00380845 0.00502324 0.00645291 0.00812367 0.0100653 0.012312 0.0149024 0.0178799 0.0212922 0.0251883 0.02961 0.0345729 0.0400436 0.0459333 0.0521197 0.0584752 0.0648861 0.0712572 0.000298131 0.000408871 0.000730073 0.00125542 0.00193852 0.0027869 0.0038092 0.00502359 0.00645262 0.00812246 0.0100628 0.0123077 0.0148957 0.01787 0.0212783 0.0251703 0.0295893 0.0345548 0.0400379 0.0459523 0.052175 0.0585759 0.0650378 0.07146 0.000298114 0.000407848 0.000730188 0.00125587 0.00193928 0.00278752 0.00380947 0.00502329 0.00645148 0.00812017 0.010059 0.0123019 0.0148872 0.0178581 0.0212622 0.0251497 0.0295655 0.0345327 0.040027 0.045965 0.052223 0.0586686 0.0651807 0.0716559 0.000298028 0.000406802 0.000730201 0.00125613 0.00193974 0.00278773 0.00380921 0.00502228 0.00644941 0.0081167 0.0100537 0.0122943 0.0148766 0.0178437 0.0212433 0.0251258 0.0295377 0.0345056 0.0400099 0.0459705 0.0522634 0.0587533 0.0653168 0.071848 0.000297863 0.000405775 0.000730104 0.0012562 0.00193992 0.00278755 0.00380835 0.00502048 0.00644636 0.00811193 0.0100469 0.0122847 0.0148637 0.0178266 0.0212212 0.025098 0.0295051 0.0344723 0.0399851 0.0459671 0.0522942 0.0588288 0.0654448 0.0720357 0.000297594 0.000404765 0.000729842 0.00125602 0.00193977 0.00278688 0.00380684 0.00501783 0.00644223 0.00810587 0.0100383 0.0122731 0.0148483 0.0178065 0.0211954 0.0250658 0.029467 0.0344319 0.0399512 0.0459527 0.0523126 0.0588909 0.0655584 0.0722064 0.00029724 0.000403668 0.000729482 0.00125566 0.00193932 0.00278579 0.00380478 0.00501444 0.0064371 0.00809853 0.0100282 0.0122596 0.0148304 0.0177834 0.0211659 0.025029 0.029423 0.0343839 0.0399074 0.0459258 0.0523162 0.0589362 0.0656534 0.072356 0.000296796 0.000402547 0.000729031 0.00125514 0.00193859 0.00278429 0.00380216 0.00501031 0.00643101 0.00808995 0.0100165 0.012244 0.0148101 0.0177572 0.0211326 0.0249876 0.0293732 0.0343281 0.0398533 0.0458859 0.0523043 0.0589638 0.065728 0.0724807 0.000296269 0.00040131 0.000728451 0.0012544 0.00193755 0.00278239 0.003799 0.00500546 0.006424 0.00808021 0.0100033 0.0122266 0.0147875 0.0177282 0.0210959 0.0249418 0.0293178 0.0342649 0.0397891 0.0458331 0.0522772 0.0589747 0.0657857 0.0725918 0.000295665 0.000400007 0.000727703 0.0012534 0.00193615 0.00277998 0.00379516 0.00499981 0.00641604 0.0080693 0.00998874 0.0122075 0.0147628 0.0176966 0.0210561 0.0248921 0.0292571 0.0341947 0.0397152 0.0457673 0.0522343 0.058968 0.0658256 0.0726878 0.000294991 0.000398618 0.000726838 0.00125219 0.00193442 0.00277711 0.00379075 0.00499339 0.0064071 0.00805725 0.00997282 0.0121868 0.0147362 0.0176628 0.0210134 0.024839 0.0291922 0.0341183 0.0396324 0.0456889 0.0521746 0.0589403 0.0658396 0.0727467 0.00029427 0.000397206 0.000725861 0.00125077 0.00193237 0.00277378 0.0037857 0.00498619 0.00639719 0.00804401 0.00995551 0.0121645 0.0147077 0.0176269 0.0209684 0.0247832 0.0291239 0.0340375 0.0395429 0.0456003 0.0521004 0.0588938 0.0658315 0.0727835 0.00029347 0.000395747 0.000724745 0.00124912 0.00192994 0.00276993 0.00378 0.00497815 0.00638626 0.00802953 0.00993672 0.0121405 0.0146774 0.0175889 0.0209211 0.0247248 0.029053 0.0339535 0.039449 0.045505 0.0520162 0.0588337 0.065807 0.0728103 0.000292579 0.000394178 0.000723458 0.00124718 0.0019271 0.00276556 0.00377362 0.00496925 0.00637427 0.00801379 0.00991645 0.0121147 0.0146451 0.0175487 0.0208715 0.0246639 0.0289792 0.0338665 0.0393515 0.0454052 0.051926 0.0587643 0.0657643 0.0727865 0.000291602 0.000392547 0.000722042 0.00124502 0.00192394 0.0027607 0.00376655 0.00495948 0.00636123 0.00799682 0.00989471 0.0120873 0.0146108 0.0175062 0.0208193 0.0246002 0.0289023 0.0337759 0.0392497 0.0453004 0.0518314 0.0586941 0.0657326 0.072813 0.000290572 0.000390836 0.000720527 0.00124268 0.00192047 0.00275537 0.00375887 0.00494891 0.00634717 0.00797856 0.00987148 0.0120581 0.0145745 0.0174615 0.0207644 0.0245335 0.0288219 0.0336807 0.0391418 0.0451869 0.0517247 0.0586081 0.0656789 0.0727971 0.000289514 0.000389123 0.000718975 0.00124024 0.00191678 0.0027497 0.0037507 0.00493765 0.00633218 0.00795913 0.00984679 0.0120272 0.0145363 0.0174145 0.0207072 0.0244641 0.0287384 0.0335817 0.0390284 0.0450649 0.0516049 0.0585031 0.0655996 0.0727508 0.000288387 0.00038739 0.000717369 0.00123766 0.00191288 0.00274374 0.0037421 0.00492578 0.00631636 0.00793863 0.00982075 0.0119947 0.0144961 0.0173653 0.0206475 0.0243921 0.0286522 0.0334799 0.0389115 0.0449379 0.0514775 0.0583868 0.0655054 0.072693 0.000287188 0.000385598 0.000715736 0.00123506 0.00190892 0.00273763 0.00373321 0.00491349 0.00629996 0.00791729 0.00979358 0.0119606 0.0144541 0.017314 0.0205854 0.0243174 0.0285632 0.0333754 0.038792 0.0448082 0.0513467 0.0582656 0.0654013 0.0726012 0.000285927 0.000383777 0.000714113 0.00123247 0.00190498 0.00273151 0.00372424 0.00490101 0.00628323 0.00789544 0.00976561 0.0119254 0.0144105 0.0172606 0.0205206 0.0242396 0.0284708 0.0332672 0.0386688 0.0446748 0.0512127 0.058142 0.0652993 0.0725396 0.000284636 0.000381909 0.000712524 0.00122993 0.0019011 0.00272546 0.00371537 0.0048886 0.00626647 0.00787342 0.00973731 0.0118896 0.0143658 0.0172057 0.0204536 0.0241589 0.0283745 0.0331542 0.0385399 0.044535 0.0510721 0.0580123 0.0651868 0.0724285 0.000283329 0.000380067 0.000710983 0.00122746 0.00189732 0.00271957 0.00370673 0.00487648 0.00625003 0.0078517 0.0097092 0.0118539 0.014321 0.0171501 0.0203854 0.024076 0.0282749 0.0330361 0.0384035 0.044385 0.0509196 0.057874 0.0650852 0.0724086 0.000281963 0.000378219 0.000709469 0.00122506 0.00189364 0.00271395 0.00369841 0.00486481 0.00623418 0.00783067 0.00968189 0.011819 0.014277 0.0170951 0.0203174 0.0239927 0.0281738 0.0329147 0.0382606 0.0442234 0.0507477 0.0577039 0.0649257 0.0722539 0.000280531 0.000376315 0.000707963 0.00122272 0.00189012 0.00270847 0.00369033 0.00485349 0.00621895 0.00781054 0.0096557 0.0117855 0.0142345 0.017042 0.0202514 0.0239112 0.028074 0.0327936 0.0381164 0.0440568 0.0505657 0.0575182 0.064749 0.0720981 0.000279081 0.000374363 0.000706473 0.00122041 0.00188666 0.00270313 0.00368256 0.00484266 0.00620433 0.00779129 0.00963078 0.0117536 0.0141942 0.0169915 0.0201885 0.0238335 0.0279784 0.032677 0.037976 0.0438926 0.0503822 0.0573256 0.0645597 0.0719201 0.000277621 0.000372423 0.000705005 0.00121811 0.00188322 0.00269786 0.00367493 0.0048321 0.00619018 0.00777275 0.00960695 0.0117233 0.0141562 0.0169439 0.0201295 0.0237606 0.027889 0.0325678 0.0378439 0.0437365 0.0502046 0.0571342 0.0643675 0.0717507 0.000276114 0.000370497 0.000703587 0.00121588 0.00187983 0.00269264 0.00366742 0.00482175 0.00617636 0.00775474 0.00958391 0.0116943 0.0141199 0.0168989 0.0200741 0.0236927 0.0278061 0.0324672 0.037723 0.0435936 0.0500405 0.0569521 0.0641705 0.0715346 0.000274556 0.00036852 0.000702208 0.00121369 0.00187644 0.00268746 0.00365995 0.00481147 0.00616268 0.007737 0.00956133 0.0116659 0.0140847 0.0168557 0.0200213 0.0236286 0.0277287 0.0323746 0.0376133 0.043466 0.0498962 0.056794 0.0640034 0.0713667 0.000272952 0.000366515 0.000700861 0.00121157 0.00187306 0.00268225 0.00365242 0.00480113 0.00614899 0.00771931 0.00953887 0.0116379 0.0140501 0.0168134 0.01997 0.0235668 0.0276548 0.0322871 0.0375112 0.0433498 0.049768 0.0566567 0.06386 0.0712198 0.000271321 0.000364451 0.000699538 0.0012096 0.00186967 0.00267698 0.00364483 0.00479071 0.00613516 0.00770145 0.00951628 0.0116097 0.0140154 0.016771 0.0199188 0.0235055 0.0275819 0.0322014 0.0374123 0.0432387 0.0496479 0.0565313 0.0637314 0.0710857 0.000269677 0.000362416 0.000698274 0.0012077 0.00186634 0.00267178 0.00363731 0.00478032 0.00612127 0.00768348 0.00949347 0.0115812 0.0139803 0.0167283 0.0198672 0.0234436 0.0275085 0.0321151 0.0373128 0.0431276 0.049529 0.0564102 0.0636131 0.0709737 0.000267976 0.000360363 0.000697013 0.00120582 0.00186305 0.00266664 0.00362984 0.00476997 0.0061074 0.0076654 0.00947051 0.0115525 0.0139447 0.0166848 0.0198146 0.0233806 0.0274335 0.032027 0.0372109 0.0430132 0.0494063 0.0562846 0.0634904 0.0708643 0.000266209 0.000358246 0.000695743 0.00120395 0.0018598 0.00266153 0.00362241 0.00475971 0.00609367 0.00764746 0.00944753 0.0115235 0.0139088 0.0166408 0.0197612 0.0233163 0.0273568 0.0319366 0.0371062 0.0428956 0.0492801 0.0561548 0.0633574 0.0707147 0.00026441 0.000356069 0.000694459 0.00120206 0.00185656 0.00265645 0.003615 0.00474953 0.00608003 0.00762964 0.00942469 0.0114947 0.0138728 0.0165964 0.019707 0.0232507 0.0272783 0.0318437 0.0369983 0.0427748 0.0491525 0.0560299 0.0632448 0.070627 0.000262591 0.000353903 0.000693193 0.0012002 0.00185335 0.00265144 0.00360775 0.00473949 0.00606657 0.00761204 0.00940211 0.0114661 0.0138371 0.0165522 0.0196526 0.0231846 0.0271985 0.0317482 0.0368864 0.0426482 0.0490179 0.0558991 0.0631293 0.0705246 0.000260715 0.000351722 0.000691893 0.00119829 0.00185006 0.00264636 0.00360045 0.00472945 0.00605319 0.0075946 0.00937979 0.0114379 0.0138018 0.0165084 0.0195988 0.0231187 0.0271184 0.0316516 0.0367714 0.0425151 0.0488724 0.0557545 0.0630079 0.0704723 0.000258776 0.000349461 0.000690536 0.00119628 0.00184665 0.00264115 0.00359301 0.00471929 0.00603972 0.00757714 0.00935755 0.01141 0.0137671 0.0164655 0.019546 0.0230541 0.0270397 0.0315562 0.0366568 0.0423799 0.048719 0.0555891 0.0628359 0.0702836 0.000256773 0.000347131 0.000689089 0.00119413 0.00184305 0.00263568 0.00358522 0.00470872 0.00602587 0.00755936 0.00933508 0.0113819 0.0137324 0.0164229 0.0194941 0.022991 0.0269632 0.031464 0.0365465 0.0422504 0.0485724 0.0554328 0.0626826 0.0701535 0.000254732 0.000344723 0.000687638 0.00119195 0.00183934 0.00263 0.00357715 0.00469778 0.00601151 0.007541 0.00931201 0.0113533 0.0136972 0.0163801 0.0194422 0.0229286 0.0268883 0.0313747 0.0364408 0.0421276 0.0484347 0.0552863 0.0625365 0.0700178 0.000252697 0.000342333 0.000686259 0.00118982 0.00183562 0.00262423 0.00356888 0.00468648 0.0059966 0.00752186 0.00928795 0.0113235 0.0136608 0.016336 0.0193892 0.0228653 0.0268132 0.0312859 0.0363371 0.0420087 0.0483029 0.0551468 0.0623959 0.0698822 0.000250598 0.000340003 0.000684968 0.00118776 0.00183195 0.00261848 0.00356054 0.00467495 0.00598126 0.00750204 0.00926289 0.0112924 0.0136227 0.0162898 0.0193338 0.0227993 0.0267353 0.0311947 0.0362316 0.0418893 0.0481726 0.055011 0.0622596 0.0697481 0.000248405 0.000337561 0.00068371 0.0011858 0.00182843 0.00261286 0.00355225 0.00466341 0.00596578 0.00748183 0.0092371 0.0112601 0.0135828 0.0162413 0.0192754 0.0227295 0.0266527 0.0310981 0.03612 0.0417637 0.0480371 0.0548723 0.0621242 0.06962 0.000246153 0.000335122 0.000682638 0.00118412 0.0018253 0.00260771 0.00354446 0.00465235 0.00595071 0.00746189 0.0092113 0.0112273 0.013542 0.016191 0.0192141 0.0226557 0.0265647 0.0309941 0.0359991 0.0416265 0.0478883 0.0547201 0.0619764 0.0694814 0.000243868 0.000332654 0.000681785 0.00118281 0.00182266 0.0026032 0.0035375 0.00464222 0.00593662 0.00744292 0.0091864 0.0111953 0.0135013 0.0161402 0.0191514 0.0225791 0.0264721 0.0308832 0.035868 0.0414751 0.0477206 0.0545461 0.0618064 0.0693179 0.000241579 0.000330245 0.000681223 0.00118197 0.0018207 0.0025996 0.00353169 0.00463352 0.00592418 0.00742577 0.00916343 0.0111652 0.0134626 0.016091 0.0190897 0.0225024 0.0263779 0.0307683 0.0357294 0.041311 0.0475335 0.0543459 0.061609 0.0691427 0.000239278 0.000327896 0.000680929 0.00118158 0.00181944 0.00259702 0.00352725 0.00462654 0.00591386 0.00741115 0.00914337 0.0111383 0.0134274 0.0160455 0.0190317 0.0224292 0.0262862 0.0306548 0.0355898 0.0411415 0.0473335 0.0541212 0.0613707 0.0688998 0.000236907 0.000325642 0.000680903 0.00118165 0.00181892 0.00259549 0.0035242 0.0046214 0.00590593 0.00739952 0.0091269 0.0111157 0.013397 0.0160055 0.0189798 0.0223628 0.0262019 0.0305487 0.0354575 0.0409785 0.047137 0.0538938 0.0611204 0.0686352 0.000234475 0.000323365 0.000681053 0.00118209 0.00181902 0.0025949 0.00352254 0.00461816 0.00590046 0.00739103 0.0091144 0.0110979 0.0133725 0.0159724 0.0189359 0.0223055 0.0261281 0.0304549 0.0353393 0.0408319 0.0469597 0.0536883 0.0608927 0.0683875 0.00023201 0.00032116 0.000681376 0.00118293 0.00181978 0.00259528 0.00352225 0.00461679 0.00589746 0.00738571 0.00910589 0.0110852 0.013354 0.0159466 0.0189008 0.0222587 0.0260667 0.0303754 0.0352381 0.0407055 0.046807 0.0535143 0.0607106 0.0682134 0.000229525 0.000319094 0.000681926 0.00118415 0.00182106 0.00259641 0.00352313 0.00461705 0.00589666 0.00738327 0.00910109 0.0110771 0.0133415 0.0159281 0.0188746 0.0222225 0.0260179 0.0303109 0.0351543 0.0405987 0.0466748 0.0533583 0.060539 0.0680456 0.000227016 0.000317206 0.000682573 0.00118554 0.00182267 0.00259816 0.00352494 0.00461865 0.00589768 0.00738328 0.00909949 0.0110731 0.0133341 0.0159162 0.0188565 0.0221964 0.0259815 0.0302613 0.0350885 0.0405134 0.0465675 0.0532294 0.0603917 0.0678735 0.000224457 0.000315556 0.00068324 0.00118707 0.00182459 0.00260034 0.00352734 0.00462115 0.00589997 0.00738509 0.00910031 0.0110723 0.0133309 0.0159096 0.0188452 0.0221787 0.0259556 0.0302251 0.0350394 0.040449 0.0464866 0.0531336 0.0602894 0.0677906 0.000221742 0.000314026 0.0006839 0.00118863 0.00182656 0.00260285 0.00353017 0.0046241 0.00590299 0.00738797 0.00910259 0.0110736 0.0133305 0.0159066 0.0188386 0.0221673 0.0259377 0.0301989 0.0350031 0.0404012 0.0464268 0.053064 0.0602168 0.0677267 0.000219153 0.000312855 0.000684687 0.00119007 0.00182843 0.00260529 0.00353279 0.00462692 0.00590616 0.00739118 0.00910544 0.0110756 0.0133314 0.0159054 0.0188345 0.0221592 0.0259242 0.0301785 0.0349743 0.0403627 0.0463782 0.0530064 0.0601528 0.0676587 0.000216672 0.000312195 0.000685501 0.00119167 0.00183047 0.0026077 0.00353556 0.00462991 0.00590928 0.00739419 0.0091081 0.0110776 0.0133321 0.0159043 0.0188307 0.0221517 0.0259118 0.0301598 0.0349479 0.0403273 0.0463332 0.0529503 0.0600807 0.067558 0.000214246 0.000311877 0.000686346 0.00119319 0.00183243 0.00260996 0.00353804 0.00463254 0.00591183 0.00739646 0.00910983 0.0110784 0.0133315 0.0159016 0.0188251 0.0221422 0.0258972 0.0301388 0.0349192 0.0402903 0.0462882 0.0528984 0.0600204 0.0674882 0.000211708 0.000311821 0.000687143 0.00119462 0.00183428 0.002612 0.00354016 0.00463463 0.0059137 0.00739763 0.00911007 0.0110774 0.0133285 0.015896 0.0188159 0.0221283 0.0258775 0.0301115 0.034883 0.0402442 0.046233 0.0528363 0.0599526 0.0674153 0.000209024 0.000311738 0.000687897 0.00119602 0.00183589 0.00261369 0.0035418 0.00463602 0.00591458 0.00739768 0.0091087 0.0110742 0.0133229 0.0158869 0.0188024 0.0221089 0.0258506 0.0300754 0.0348354 0.0401834 0.0461583 0.0527475 0.059844 0.0672671 0.000206232 0.000311758 0.000688708 0.00119744 0.00183748 0.00261528 0.00354323 0.004637 0.00591484 0.00739676 0.00910604 0.0110691 0.0133145 0.0158743 0.0187842 0.0220836 0.0258162 0.0300297 0.0347758 0.0401074 0.0460651 0.0526389 0.0597188 0.0671069 0.00020335 0.000311872 0.00068963 0.00119901 0.00183924 0.00261694 0.00354464 0.00463797 0.0059148 0.00739534 0.00910254 0.0110626 0.0133042 0.0158588 0.018762 0.0220529 0.0257748 0.0299749 0.0347045 0.0400167 0.0459537 0.0525099 0.0595783 0.066964 0.00020038 0.000312093 0.000690733 0.00120084 0.00184124 0.0026188 0.00354641 0.0046394 0.00591508 0.00739395 0.00909893 0.0110557 0.0132927 0.0158414 0.018737 0.0220182 0.0257277 0.0299125 0.0346232 0.039913 0.0458261 0.0523626 0.059421 0.0668065 0.00019732 0.000312437 0.000692073 0.00120303 0.00184369 0.00262146 0.00354918 0.0046417 0.00591621 0.00739346 0.00909622 0.0110495 0.0132817 0.0158239 0.018711 0.0219813 0.0256771 0.0298446 0.034534 0.0397984 0.0456842 0.0521986 0.0592515 0.0666524 0.000194164 0.00031293 0.000693721 0.00120575 0.00184705 0.00262528 0.0035532 0.00464552 0.0059193 0.00739511 0.00909552 0.0110453 0.0132725 0.0158081 0.0186862 0.021945 0.025626 0.0297747 0.0344405 0.039676 0.0455288 0.0520116 0.0590454 0.066446 0.000190873 0.000313568 0.000695663 0.00120905 0.0018513 0.00263029 0.00355878 0.00465126 0.00592472 0.00739952 0.00909797 0.0110445 0.0132671 0.0157961 0.0186655 0.0219127 0.0255785 0.0297076 0.0343486 0.0395531 0.0453689 0.0518141 0.058817 0.0661981 0.00018735 0.00031423 0.000698018 0.0012131 0.00185663 0.00263684 0.00356623 0.00465922 0.00593298 0.00740747 0.00910457 0.0110485 0.0132669 0.0157901 0.0186515 0.0218875 0.0255385 0.0296484 0.0342648 0.0394382 0.0452164 0.0516208 0.0585864 0.0659177 0.000183834 0.000315251 0.000701022 0.00121794 0.00186305 0.00264497 0.00357565 0.00466969 0.00594449 0.00741941 0.00911588 0.0110578 0.0132729 0.0157915 0.0186459 0.0218718 0.0255092 0.0296014 0.0341948 0.039339 0.0450816 0.0514469 0.0583814 0.0657215 0.000180293 0.0003166 0.000704468 0.00122346 0.00187069 0.00265491 0.00358766 0.00468357 0.00595989 0.00743581 0.00913235 0.0110735 0.0132865 0.0158012 0.0186497 0.0218668 0.0254923 0.0295687 0.0341418 0.0392605 0.0449726 0.0513051 0.0582075 0.0654951 0.000176637 0.000318248 0.000708542 0.00123011 0.00187986 0.00266669 0.00360207 0.00470049 0.00597903 0.00745669 0.00915409 0.0110954 0.0133075 0.0158194 0.018663 0.0218727 0.0254876 0.0295501 0.034105 0.0392013 0.0448886 0.0512013 0.0581102 0.0654781 0.000172877 0.000320273 0.000713298 0.00123768 0.0018905 0.00268047 0.00361907 0.00472064 0.00600214 0.00748219 0.00918146 0.0111239 0.0133358 0.0158459 0.0186855 0.0218888 0.0254945 0.0295439 0.0340813 0.0391552 0.0448147 0.0510955 0.0579719 0.0652971 0.000169047 0.000322756 0.000718965 0.0012464 0.0019028 0.00269643 0.00363882 0.00474418 0.00602927 0.00751233 0.00921425 0.0111587 0.0133712 0.0158802 0.0187165 0.0219144 0.0255118 0.0295488 0.0340698 0.039122 0.0447545 0.0510043 0.0578525 0.0651663 0.000164954 0.000325683 0.000725588 0.00125653 0.00191684 0.0027147 0.00366149 0.00477126 0.00606061 0.00754759 0.00925281 0.0111997 0.0134134 0.015922 0.0187558 0.0219487 0.0255379 0.0295633 0.0340685 0.0391003 0.0447079 0.05093 0.0577516 0.065036 0.000160522 0.000328862 0.000732885 0.00126786 0.00193271 0.00273544 0.0036873 0.0048022 0.00609651 0.00758806 0.00929718 0.011247 0.0134623 0.0159708 0.0188023 0.0219901 0.0255709 0.0295841 0.0340728 0.0390839 0.0446672 0.0508654 0.0576701 0.0649442 0.000155802 0.000332599 0.000741267 0.00128093 0.00195103 0.0027593 0.00371702 0.00483795 0.00613796 0.00763478 0.00934844 0.0113017 0.0135189 0.016027 0.0188557 0.0220379 0.0256091 0.0296081 0.0340777 0.0390642 0.0446182 0.0507865 0.0575699 0.0648264 0.000150727 0.000336988 0.000750941 0.0012961 0.00197223 0.0027869 0.00375161 0.00487966 0.0061862 0.00768914 0.00940824 0.0113654 0.0135848 0.0160924 0.018918 0.0220935 0.0256531 0.0296351 0.034081 0.0390361 0.0445503 0.0506728 0.057417 0.0646571 0.00014519 0.000342172 0.000762181 0.00131379 0.00199701 0.00281947 0.00379247 0.00492867 0.00624293 0.0077532 0.00947884 0.0114408 0.013663 0.0161707 0.0189928 0.0221605 0.025707 0.0296693 0.0340873 0.0390047 0.0444685 0.0505249 0.0571916 0.0643583 0.00013901 0.000348314 0.000775328 0.00133461 0.00202642 0.00285813 0.00384078 0.00498672 0.00631046 0.0078295 0.00956287 0.0115309 0.0137568 0.0162652 0.0190842 0.0222439 0.0257765 0.0297179 0.0341065 0.0389839 0.044395 0.0503847 0.0569789 0.0641011 0.00013193 0.0003556 0.000790696 0.00135916 0.00206116 0.00290383 0.00389794 0.00505547 0.00639056 0.00792019 0.00966287 0.0116385 0.0138693 0.0163794 0.0191958 0.022348 0.0258668 0.0297872 0.0341464 0.0389844 0.0443445 0.0502712 0.0567988 0.063903 0.000123432 0.000364252 0.000808812 0.0013882 0.00210231 0.00295804 0.0039656 0.00513669 0.00648533 0.00802771 0.00978154 0.011766 0.0140028 0.0165156 0.0193303 0.0224751 0.0259802 0.0298798 0.0342102 0.0390103 0.0443227 0.0501905 0.0566455 0.0636564 0.000113125 0.000374889 0.000830569 0.00142272 0.00215116 0.00302244 0.00404582 0.00523281 0.00659733 0.00815453 0.00992121 0.0119158 0.0141594 0.0166754 0.0194883 0.0226251 0.0261157 0.0299932 0.0342942 0.0390575 0.0443265 0.0501489 0.0565717 0.0636115 0.000101265 0.000387943 0.000856642 0.00146413 0.00220976 0.00309956 0.00414184 0.00534769 0.00673031 0.00830417 0.010085 0.0120908 0.0143418 0.01686 0.0196694 0.022796 0.0262691 0.0301214 0.0343887 0.0391107 0.0443308 0.0500977 0.056462 0.0634452 9.10798e-05 0.000403805 0.000888483 0.00151486 0.0022813 0.00319306 0.00425773 0.00548556 0.00688894 0.0084814 0.0102775 0.0122948 0.0145524 0.0170711 0.019874 0.0229862 0.026437 0.0302583 0.034485 0.0391571 0.0443177 0.0500153 0.0563019 0.0632116 8.97259e-05 0.000423392 0.000928633 0.00157858 0.00237084 0.00330933 0.00440076 0.00565434 0.00708139 0.00869411 0.0105064 0.0125346 0.0147966 0.0173123 0.020104 0.0231965 0.0266182 0.0304007 0.0345784 0.0391905 0.0442795 0.0498926 0.0560814 0.0628886 9.41336e-05 0.000447859 0.000980282 0.00166104 0.0024866 0.00345888 0.00458326 0.00586753 0.00732163 0.00895625 0.0107845 0.0128218 0.0150846 0.0175923 0.0203664 0.0234318 0.0268164 0.0305513 0.0346708 0.0392126 0.0442183 0.0497333 0.0558074 0.0624923 9.93976e-05 0.000479911 0.00105048 0.00177496 0.00264694 0.00366531 0.00483293 0.00615544 0.007641 0.00929891 0.0111413 0.0131828 0.0154398 0.0179313 0.0206788 0.0237074 0.0270449 0.0307225 0.0347739 0.039236 0.0441485 0.0495535 0.0554949 0.0620144 0.000110155 0.000559342 0.0012003 0.00200044 0.00294688 0.0040331 0.00525963 0.00662928 0.00814822 0.00982446 0.0116699 0.0137001 0.0159341 0.0183908 0.0210929 0.0240669 0.0273412 0.0309471 0.034918 0.0392899 0.0441007 0.0493901 0.0551994 0.0615731 0.000160323 0.000834264 0.00169803 0.0026887 0.00378184 0.0049744 0.00627356 0.0076876 0.00922453 0.0108926 0.0127047 0.0146784 0.0168347 0.0191985 0.0217995 0.0246719 0.0278416 0.0313398 0.0351994 0.0394551 0.0441427 0.0492989 0.0549593 0.0611574 0.000561721 0.00205627 0.0040187 0.00619598 0.00854205 0.0110275 0.0136328 0.0163357 0.019127 0.0220008 0.024951 0.0279712 0.0310575 0.0342079 0.0374208 0.0406935 0.0440226 0.0474047 0.0508341 0.0543036 0.0578057 0.0613322 0.0648754 0.068451 0.000260673 0.00128848 0.0027211 0.00442426 0.00635602 0.00848886 0.0108031 0.0132817 0.0159111 0.0186796 0.021576 0.0245901 0.0277118 0.0309322 0.0342426 0.0376344 0.0410986 0.0446273 0.0482108 0.0518399 0.0555047 0.0591953 0.0629017 0.0666234 0.000244839 0.00105014 0.00222826 0.00364298 0.00528154 0.00713217 0.0091858 0.0114331 0.0138654 0.0164729 0.0192451 0.0221713 0.0252394 0.0284378 0.0317546 0.0351775 0.0386946 0.0422939 0.0459631 0.0496902 0.0534632 0.0572706 0.0611029 0.0649589 0.000275198 0.000856316 0.00185377 0.00307866 0.00452443 0.00618329 0.00804992 0.010119 0.0123853 0.0148429 0.0174841 0.0203004 0.0232821 0.0264182 0.0296968 0.033105 0.0366292 0.0402558 0.0439702 0.0477582 0.0516056 0.0554986 0.0594249 0.0633828 0.000294124 0.000734734 0.00161451 0.00270852 0.00401367 0.00552508 0.00724065 0.00915863 0.0112774 0.0135945 0.0161057 0.0188055 0.0216871 0.0247413 0.0279576 0.031324 0.0348267 0.0384514 0.0421824 0.0460038 0.0498992 0.0538521 0.0578454 0.0618694 0.000300816 0.000657669 0.00145515 0.0024519 0.00364781 0.00504076 0.00663141 0.00842089 0.0104105 0.0126009 0.0149906 0.0175772 0.0203565 0.0233218 0.0264645 0.0297739 0.0332372 0.0368404 0.0405673 0.0444012 0.0483242 0.0523177 0.0563623 0.0604492 0.000302735 0.000601371 0.00133285 0.00225319 0.00336192 0.00465887 0.00614654 0.007828 0.00970671 0.0117855 0.0140655 0.0165467 0.0192272 0.0221029 0.0251674 0.0284117 0.0318246 0.0353929 0.0391009 0.0429316 0.0468664 0.0508855 0.0549687 0.0591057 0.0003034 0.000557363 0.00123421 0.00209261 0.00313005 0.00434756 0.00574893 0.00733858 0.00912148 0.0111021 0.0132836 0.0156679 0.0182553 0.0210439 0.0240295 0.027205 0.030561 0.0340855 0.0377639 0.0415794 0.0455134 0.0495455 0.0536542 0.0578242 0.00030347 0.000521734 0.00115301 0.00196002 0.00293779 0.00408821 0.00541591 0.00692637 0.00862561 0.0105194 0.0126123 0.014908 0.0174086 0.0201141 0.0230223 0.026128 0.0294237 0.0328989 0.0365401 0.0403314 0.0442544 0.0482883 0.0524101 0.0565989 0.00030323 0.000492006 0.00108445 0.00184794 0.00277477 0.00386755 0.00513151 0.00657284 0.00819838 0.0100148 0.012028 0.0142427 0.0166629 0.01929 0.0221235 0.0251603 0.0283943 0.0318169 0.0354158 0.0391762 0.0430803 0.047107 0.0512328 0.0554343 0.000302919 0.000466948 0.00102645 0.00175142 0.00263402 0.00367657 0.00488472 0.00626511 0.00782517 0.00957237 0.0115134 0.0136543 0.016 0.0185535 0.0213158 0.0242852 0.0274577 0.030826 0.0343794 0.0381042 0.0419834 0.0459967 0.0501204 0.0543322 0.000302621 0.000445707 0.000976842 0.0016672 0.0025109 0.00350918 0.0046679 0.00599402 0.00749547 0.00918027 0.0110558 0.013129 0.0154057 0.0178903 0.0205849 0.0234895 0.0266015 0.0299151 0.0334212 0.0371074 0.0409579 0.0449532 0.0490704 0.0532878 0.000302325 0.000427383 0.000933432 0.0015928 0.002402 0.00336087 0.0044754 0.00575286 0.00720148 0.00882971 0.0106455 0.0126564 0.0148692 0.0172892 0.0199199 0.0227623 0.0258154 0.0290748 0.0325331 0.0361792 0.039999 0.0439746 0.0480852 0.0523085 0.000302014 0.000411357 0.000894934 0.00152648 0.00230477 0.00322828 0.00430303 0.00553652 0.00693719 0.00851383 0.0102748 0.0122283 0.0143818 0.0167415 0.0193117 0.0220947 0.0250909 0.0282974 0.0317081 0.0353138 0.0391023 0.0430585 0.0471672 0.051414 0.00030171 0.000397186 0.000860434 0.0014668 0.00221726 0.00310882 0.00414752 0.00534102 0.00669793 0.00822729 0.00993783 0.0118382 0.0139365 0.0162396 0.0187528 0.0214795 0.024421 0.027576 0.0309398 0.034505 0.0382607 0.0421937 0.0462886 0.0505229 0.000301493 0.000385378 0.000829571 0.00141348 0.002138 0.00300043 0.00400629 0.00516318 0.00647994 0.00796581 0.00962978 0.0114809 0.0135278 0.0157779 0.0182372 0.0209102 0.0237993 0.0269044 0.0302219 0.0337458 0.0374662 0.0413694 0.0454361 0.0496301 0.000301989 0.000379903 0.000801945 0.00136548 0.00206588 0.00290159 0.00387723 0.00500054 0.00628034 0.007726 0.0093468 0.0111521 0.0131509 0.0153512 0.0177596 0.0203816 0.0232204 0.0262768 0.0295486 0.0330305 0.0367134 0.0405828 0.0446181 0.0487846 0.000303496 0.000380922 0.000777134 0.00132181 0.00199982 0.00281091 0.00375876 0.00485107 0.00609668 0.00750507 0.0090857 0.0108482 0.0128019 0.0149553 0.0173156 0.0198889 0.0226793 0.0256885 0.0289151 0.032355 0.0359993 0.0398351 0.0438452 0.0480118 0.000305526 0.000384318 0.000754733 0.00128181 0.001939 0.00272735 0.00364951 0.0047131 0.00592696 0.00730065 0.00884379 0.0105662 0.0124776 0.0145867 0.0169013 0.0194281 0.022172 0.0251353 0.0283176 0.0317154 0.035321 0.0391218 0.0430998 0.0472263 0.000307548 0.00038768 0.00073437 0.00124497 0.00188274 0.00265 0.00354834 0.00458522 0.00576949 0.00711077 0.0086188 0.0103036 0.0121751 0.0142424 0.0165136 0.018996 0.0216951 0.0246139 0.0277529 0.0311092 0.0346761 0.0384421 0.0423913 0.0465071 0.000309337 0.000390284 0.000715682 0.00121088 0.00183059 0.00257813 0.00345426 0.00446625 0.00562293 0.00693381 0.00840891 0.0100583 0.0118922 0.0139197 0.0161496 0.0185896 0.0212456 0.0241214 0.0272181 0.0305338 0.0340628 0.0377948 0.0417153 0.0458047 0.000310827 0.000392134 0.000698536 0.00117946 0.00178263 0.00251122 0.00336652 0.00435519 0.0054859 0.00676836 0.00821245 0.0098285 0.0116267 0.0136165 0.0158071 0.0182065 0.0208211 0.0236553 0.0267111 0.0299874 0.0334794 0.0371787 0.041073 0.0451512 0.000312051 0.000393387 0.000682751 0.00115038 0.00173812 0.00244873 0.00328447 0.00425122 0.00535761 0.00661321 0.00802805 0.00961253 0.0113768 0.0133309 0.015484 0.0178445 0.0204194 0.0232137 0.0262299 0.029468 0.0329245 0.0365924 0.0404616 0.0445205 0.000313105 0.00039426 0.000668294 0.00112342 0.00169658 0.00239018 0.0032075 0.00415363 0.00523706 0.00646733 0.00785454 0.00940905 0.0111412 0.0130612 0.0151786 0.017502 0.0200388 0.0227945 0.0257726 0.0289739 0.0323961 0.0360337 0.0398787 0.0439244 0.000314042 0.000394879 0.000655743 0.00109829 0.00165768 0.00233518 0.00313509 0.00406177 0.00512352 0.00632985 0.00769087 0.00921698 0.0109187 0.0128062 0.0148894 0.0171772 0.0196774 0.0223962 0.0253376 0.0285032 0.0318917 0.0354985 0.0393154 0.0433277 0.000314914 0.000395863 0.000647685 0.00107498 0.00162113 0.00228334 0.0030668 0.0039751 0.00501635 0.00620001 0.00753617 0.00903529 0.0107079 0.0125645 0.0146151 0.0168688 0.019334 0.0220171 0.024923 0.0280539 0.0314091 0.0349845 0.0387719 0.0427603 0.000315881 0.000397928 0.000645545 0.00105359 0.00158671 0.00223438 0.00300226 0.00389316 0.00491497 0.0060771 0.00738964 0.00886308 0.0105081 0.0123351 0.0143544 0.0165755 0.019007 0.0216558 0.0245272 0.0276241 0.0309463 0.0344901 0.0382468 0.0422023 0.000317015 0.000400985 0.000647116 0.00103408 0.00155449 0.00218855 0.00294123 0.00381554 0.00481889 0.00596056 0.00725063 0.00869959 0.0103182 0.012117 0.0141064 0.0162962 0.0186952 0.0213108 0.0241488 0.0272124 0.0305021 0.0340146 0.037742 0.0416737 0.000318239 0.000404493 0.000649858 0.00101623 0.00152433 0.00214544 0.00288344 0.00374192 0.00472768 0.00584988 0.00711852 0.00854413 0.0101375 0.0119093 0.01387 0.0160297 0.0183974 0.020981 0.0237865 0.0268177 0.0300756 0.0335577 0.0372577 0.0411658 0.000319453 0.000407878 0.000652401 0.000999703 0.00149597 0.00210467 0.00282859 0.00367195 0.00464095 0.00574457 0.00699277 0.00839608 0.00996527 0.0117112 0.0136444 0.0157752 0.0181128 0.0206653 0.0234393 0.026439 0.0296661 0.0331192 0.036794 0.0406884 0.000320565 0.000410888 0.000654259 0.000984244 0.0014692 0.002066 0.00277642 0.00360535 0.00455835 0.00564423 0.0068729 0.00825487 0.00980095 0.011522 0.0134288 0.0155317 0.0178402 0.0203628 0.0231063 0.0260755 0.0292727 0.0326972 0.036345 0.0402071 0.000321567 0.000413445 0.000655357 0.000969667 0.00144383 0.00202923 0.00272671 0.00354184 0.00447956 0.00554849 0.00675848 0.00812001 0.00964393 0.0113412 0.0132225 0.0152986 0.017579 0.0200726 0.0227866 0.0257262 0.0288945 0.0322916 0.0359148 0.0397594 0.000322453 0.00041558 0.000655748 0.000955843 0.00141972 0.0019942 0.00267926 0.0034812 0.0044043 0.00545701 0.0066491 0.00799105 0.00949368 0.011168 0.013025 0.0150751 0.0173285 0.0197941 0.0224795 0.0253905 0.0285308 0.0319015 0.0355017 0.039332 0.000323239 0.00041735 0.000655534 0.00094271 0.00139677 0.00196081 0.00263403 0.00342322 0.00433233 0.00536949 0.00654443 0.00786758 0.00934978 0.0110021 0.0128355 0.0148607 0.017088 0.0195265 0.0221842 0.0250674 0.0281803 0.0315242 0.0350974 0.0388935 0.000323934 0.000418815 0.000654846 0.000930379 0.00137495 0.00192904 0.00259109 0.0033678 0.00426341 0.00528567 0.00644414 0.00774921 0.00921176 0.0108429 0.0126536 0.0146548 0.0168568 0.0192691 0.0219 0.024756 0.0278417 0.0311584 0.0347033 0.0384655 0.000324555 0.000420058 0.000653928 0.000919416 0.00135425 0.00189881 0.00255016 0.00331474 0.00419737 0.00520529 0.00634794 0.00763565 0.00907929 0.01069 0.0124788 0.0144567 0.0166343 0.0190212 0.021626 0.0244555 0.0275145 0.0308048 0.0343254 0.0380754 0.000325126 0.000421216 0.000653289 0.000911169 0.0013348 0.00187002 0.00251104 0.0032639 0.00413402 0.00512815 0.00625556 0.00752656 0.00895198 0.010543 0.0123107 0.0142662 0.0164201 0.0187824 0.0213617 0.0241652 0.0271979 0.0304621 0.0339564 0.0376746 0.000325685 0.000422494 0.000653576 0.000906751 0.00131676 0.00184259 0.00247358 0.00321512 0.00407316 0.005054 0.00616676 0.00742168 0.00882955 0.0104015 0.0121488 0.0140826 0.0162136 0.0185519 0.0211063 0.0238844 0.0268911 0.0301287 0.0335951 0.037281 0.000326272 0.000424055 0.000655084 0.000905688 0.00130018 0.00181644 0.00243765 0.00316822 0.00401464 0.0049827 0.00608135 0.00732074 0.00871167 0.0102653 0.0119928 0.0139056 0.0160143 0.0183293 0.0208594 0.0236124 0.0265934 0.0298046 0.0332442 0.0369048 0.000326907 0.000425931 0.00065761 0.000906578 0.00128491 0.00179153 0.0024032 0.00312315 0.00395835 0.00491408 0.00599912 0.00722353 0.0085981 0.010134 0.0118424 0.0137348 0.0158219 0.018114 0.0206205 0.0233489 0.0263046 0.0294904 0.0329054 0.0365475 0.000327577 0.000428007 0.000660701 0.000908203 0.00127072 0.00176775 0.00237008 0.00307973 0.00390412 0.00484796 0.00591987 0.00712982 0.00848857 0.0100073 0.0116972 0.0135697 0.0156358 0.0179058 0.0203891 0.0230935 0.0260249 0.0291865 0.0325782 0.0361933 0.000328259 0.000430154 0.00066393 0.000909831 0.00125739 0.00174504 0.00233835 0.00303818 0.0038519 0.00478421 0.0058434 0.00703938 0.00838285 0.00988492 0.0115569 0.0134102 0.0154559 0.0177043 0.0201652 0.0228466 0.0257553 0.0288965 0.0322772 0.0359185 0.000328937 0.000432237 0.000667007 0.000911126 0.00124474 0.00172333 0.00230796 0.00299835 0.00380156 0.00472269 0.0057696 0.00695208 0.00828073 0.00976669 0.0114213 0.0132559 0.0152817 0.0175093 0.0199485 0.0226079 0.025495 0.0286162 0.0319778 0.0355806 0.000329592 0.000434188 0.000669763 0.000911945 0.00123269 0.00170254 0.00227876 0.00296002 0.00375302 0.00466331 0.00569833 0.00686772 0.00818204 0.00965236 0.0112901 0.0131066 0.0151132 0.0173205 0.0197387 0.0223767 0.0252421 0.0283406 0.0316728 0.0352204 0.000330198 0.000435926 0.000672132 0.000912265 0.00122117 0.00168262 0.00225072 0.00292311 0.00370618 0.00460594 0.00562943 0.00678613 0.00808655 0.00954175 0.0111631 0.0129621 0.0149499 0.0171376 0.0195353 0.0221521 0.0249956 0.0280704 0.0313763 0.0349057 0.00033075 0.000437485 0.000674124 0.000912141 0.00121021 0.00166351 0.00222374 0.00288751 0.00366092 0.00455047 0.00556277 0.00670717 0.00799411 0.00943462 0.0110401 0.012822 0.0147917 0.0169602 0.0193378 0.0219337 0.0247552 0.0278068 0.0310887 0.034596 0.000331287 0.000438904 0.000675792 0.000911699 0.00120008 0.00164518 0.00219773 0.00285312 0.00361714 0.00449677 0.00549824 0.00663073 0.00790459 0.00933086 0.0109209 0.0126862 0.0146382 0.016788 0.0191459 0.0217212 0.0245212 0.027551 0.0308133 0.0343126 0.0003318 0.000440175 0.000677216 0.000911178 0.00119134 0.00162765 0.00217265 0.00281989 0.00357476 0.00444476 0.00543574 0.00655667 0.00781785 0.00923028 0.0108053 0.0125545 0.0144893 0.0166208 0.0189594 0.0215144 0.0242935 0.0273018 0.030542 0.0340091 0.000332256 0.000441325 0.000678545 0.000910971 0.00118482 0.00161105 0.00214844 0.0027877 0.00353369 0.00439438 0.00537515 0.00648485 0.00773371 0.00913269 0.0106931 0.0124266 0.0143446 0.0164582 0.018778 0.0213133 0.0240719 0.0270599 0.0302812 0.0337407 0.000332683 0.000442448 0.000679986 0.000911475 0.00118092 0.00159553 0.00212515 0.00275661 0.00349402 0.00434554 0.00531641 0.0064152 0.0076521 0.009038 0.0105842 0.0123024 0.0142039 0.0163001 0.0186014 0.0211175 0.0238564 0.0268244 0.0300259 0.0334613 0.000333141 0.000443661 0.000681745 0.000912887 0.00117935 0.00158116 0.00210281 0.00272662 0.00345578 0.00429822 0.00525939 0.00634758 0.00757284 0.00894602 0.0104785 0.0121817 0.0140672 0.0161463 0.0184296 0.0209269 0.0236464 0.0265946 0.0297753 0.0331872 0.000333622 0.000444959 0.000683867 0.000915102 0.00117932 0.00156783 0.0020814 0.00269771 0.00341882 0.00425233 0.00520404 0.00628193 0.00749587 0.00885667 0.0103756 0.0120643 0.0139342 0.0159966 0.0182624 0.0207412 0.0234416 0.0263702 0.0295305 0.0329218 0.000334082 0.000446324 0.000686302 0.000917865 0.00118008 0.00155541 0.00206088 0.00266978 0.003383 0.00420779 0.00515032 0.00621816 0.00742107 0.00876978 0.0102756 0.0119501 0.0138047 0.0158509 0.0180995 0.0205603 0.0232421 0.0261517 0.0292935 0.0326682 0.000334532 0.000447758 0.000688932 0.000920876 0.00118109 0.00154372 0.00204117 0.00264282 0.00334832 0.00416458 0.00509809 0.00615615 0.00734831 0.00868527 0.0101783 0.0118389 0.0136787 0.015709 0.0179408 0.0203842 0.0230483 0.0259411 0.0290713 0.0324568 0.000335 0.000449224 0.000691637 0.000923907 0.00118204 0.00153264 0.00202222 0.00261673 0.0033147 0.0041226 0.00504735 0.00609585 0.00727755 0.00860306 0.0100836 0.0117307 0.0135559 0.0155708 0.0177864 0.0202129 0.0228599 0.025736 0.0288488 0.0321982 0.000335505 0.000450719 0.000694332 0.000926817 0.00118277 0.00152205 0.00200395 0.00259148 0.00328206 0.0040818 0.00499798 0.00603718 0.00720867 0.00852301 0.00999142 0.0116254 0.0134364 0.0154362 0.0176359 0.0200461 0.0226765 0.0255361 0.0286323 0.0319719 0.000336017 0.000452154 0.000696914 0.000929497 0.00118318 0.00151188 0.00198631 0.002567 0.00325034 0.00404209 0.00494993 0.00598008 0.00714163 0.00844508 0.00990161 0.0115227 0.01332 0.0153051 0.0174894 0.0198836 0.0224975 0.02534 0.0284172 0.031729 0.000336502 0.000453504 0.00069931 0.000931887 0.00118328 0.00150213 0.00196921 0.00254323 0.00321951 0.00400346 0.00490317 0.00592448 0.00707633 0.00836915 0.00981411 0.0114227 0.0132065 0.0151773 0.0173466 0.019725 0.0223224 0.0251466 0.0282012 0.0314771 0.000336951 0.000454736 0.000701506 0.000933983 0.0011831 0.00149295 0.0019527 0.00252016 0.00318954 0.0039659 0.00485764 0.00587031 0.00701271 0.00829518 0.00972885 0.0113252 0.0130959 0.0150528 0.0172073 0.01957 0.0221507 0.0249569 0.0279925 0.0312586 0.000337372 0.000455891 0.000703511 0.000935829 0.00118278 0.00148464 0.00193679 0.00249779 0.00316046 0.0039295 0.0048133 0.00581751 0.00695069 0.00822307 0.00964575 0.0112302 0.0129881 0.0149313 0.0170712 0.0194185 0.0219828 0.0247718 0.0277909 0.0310446 0.000337807 0.000457004 0.000705368 0.00093752 0.00118254 0.00147766 0.00192157 0.00247613 0.00313225 0.00389417 0.00477012 0.00576607 0.00689024 0.00815277 0.00956472 0.0111375 0.0128828 0.0148126 0.0169382 0.0192704 0.0218188 0.0245921 0.0275983 0.0308516 0.000338243 0.000458048 0.00070712 0.000939179 0.00118265 0.00147244 0.00190716 0.00245517 0.00310484 0.00385982 0.00472808 0.00571594 0.0068313 0.0080842 0.00948565 0.0110471 0.0127801 0.0146967 0.0168083 0.0191256 0.0216584 0.0244154 0.0274021 0.0306118 0.000338639 0.000459026 0.000708824 0.000940947 0.00118336 0.0014691 0.00189361 0.00243493 0.00307825 0.0038264 0.00468712 0.00566703 0.00677379 0.00801729 0.00940847 0.0109588 0.0126798 0.0145835 0.0166813 0.018984 0.0215014 0.024242 0.0272115 0.0304145 0.000339014 0.000459984 0.000710559 0.000942944 0.00118473 0.00146742 0.00188099 0.00241542 0.00305243 0.00379388 0.00464719 0.00561934 0.00671768 0.00795199 0.00933314 0.0108725 0.0125818 0.0144728 0.0165571 0.0188454 0.0213476 0.0240721 0.0270248 0.030207 0.000339422 0.000461005 0.000712418 0.000945247 0.00118674 0.00146694 0.00186924 0.00239663 0.00302736 0.0037622 0.00460824 0.00557278 0.0066629 0.00788823 0.00925959 0.0107883 0.012486 0.0143647 0.0164356 0.0187098 0.0211973 0.023907 0.0268468 0.030029 0.00033985 0.000462051 0.000714408 0.00094783 0.0011892 0.00146717 0.00185823 0.00237852 0.00300299 0.00373131 0.00457023 0.00552735 0.00660943 0.00782597 0.00918772 0.010706 0.0123924 0.014259 0.0163169 0.0185773 0.0210506 0.0237463 0.0266734 0.0298427 0.000340268 0.000463119 0.000716503 0.000950616 0.00119194 0.00146773 0.00184784 0.00236103 0.00297929 0.00370123 0.00453315 0.005483 0.00655721 0.00776514 0.00911749 0.0106255 0.012301 0.0141555 0.0162007 0.0184478 0.0209073 0.0235888 0.0265003 0.0296431 0.000340713 0.000464223 0.00071868 0.000953534 0.0011948 0.00146839 0.00183794 0.00234411 0.00295627 0.0036719 0.00449695 0.00543967 0.00650617 0.0077057 0.00904886 0.0105469 0.0122115 0.0140544 0.0160872 0.0183212 0.0207672 0.0234347 0.0263324 0.0294694 0.000341165 0.000465326 0.000720906 0.00095648 0.00119762 0.00146898 0.00182848 0.00232774 0.00293386 0.0036433 0.0044616 0.00539734 0.00645629 0.00764759 0.00898176 0.01047 0.012124 0.0139555 0.0159761 0.0181974 0.0206299 0.0232832 0.0261645 0.029273 0.00034161 0.000466453 0.000723142 0.000959399 0.00120033 0.00146941 0.00181938 0.00231188 0.00291206 0.00361541 0.00442716 0.00535598 0.00640755 0.00759079 0.00891617 0.0103948 0.0120384 0.0138587 0.0158675 0.0180761 0.0204954 0.0231348 0.0260019 0.0291052 0.000342063 0.000467554 0.000725335 0.000962223 0.00120286 0.00146963 0.00181066 0.00229649 0.00289084 0.00358828 0.00439371 0.0053156 0.00635992 0.00753526 0.008852 0.0103212 0.0119547 0.0137641 0.0157612 0.0179575 0.0203637 0.0229895 0.0258431 0.028931 0.0003425 0.000468621 0.000727439 0.000964902 0.00120519 0.00146965 0.00180232 0.00228154 0.00287019 0.00356187 0.00436108 0.00527615 0.00631333 0.00748094 0.00878923 0.0102493 0.0118728 0.0136715 0.0156572 0.0178414 0.020235 0.022848 0.0256896 0.0287719 0.000342913 0.00046961 0.000729441 0.000967421 0.00120731 0.00146953 0.00179456 0.00226709 0.00285011 0.00353614 0.00432926 0.00523762 0.00626779 0.00742781 0.00872783 0.0101789 0.0117926 0.0135808 0.0155553 0.0177277 0.020109 0.0227093 0.0255377 0.0285993 0.000343322 0.000470605 0.00073136 0.000969799 0.00120928 0.0014694 0.00178762 0.00225316 0.0028306 0.00351105 0.00429817 0.00519995 0.00622323 0.00737582 0.00866776 0.01011 0.0117142 0.0134921 0.0154557 0.0176164 0.0199855 0.0225733 0.0253891 0.0284417 0.000343755 0.000471555 0.000733184 0.000972047 0.00121114 0.0014694 0.00178178 0.00223983 0.00281163 0.00348658 0.00426781 0.00516312 0.00617966 0.00732496 0.00860897 0.0100426 0.0116374 0.0134053 0.0153581 0.0175075 0.0198648 0.0224402 0.0252422 0.0282747 0.000344171 0.00047246 0.000734923 0.000974205 0.001213 0.0014697 0.00177726 0.00222713 0.00279319 0.0034627 0.00423816 0.00512712 0.00613703 0.00727519 0.00855141 0.00997657 0.0115622 0.0133203 0.0152626 0.0174008 0.0197465 0.0223097 0.0250997 0.0281264 0.000344567 0.000473315 0.000736594 0.000976319 0.00121495 0.00147045 0.00177411 0.00221515 0.00277533 0.00343943 0.00420918 0.00509188 0.00609529 0.00722646 0.00849506 0.00991195 0.0114886 0.013237 0.015169 0.0172962 0.0196304 0.0221819 0.0249597 0.0279717 0.000344946 0.000474143 0.000738228 0.00097845 0.00121708 0.00147172 0.00177223 0.00220391 0.00275804 0.00341674 0.00418086 0.00505741 0.00605445 0.00717876 0.00843989 0.00984866 0.0114166 0.0131555 0.0150773 0.017194 0.0195169 0.0220567 0.0248229 0.0278253 0.000345358 0.000475013 0.000739891 0.000980665 0.00121944 0.0014735 0.00177134 0.00219338 0.00274132 0.00339462 0.00415317 0.00502367 0.00601446 0.00713206 0.00838594 0.0097867 0.011346 0.0130756 0.0149876 0.0170938 0.0194056 0.0219337 0.0246874 0.0276726 0.000345788 0.000475875 0.000741588 0.000982985 0.00122202 0.00147567 0.00177115 0.00218347 0.00272513 0.00337302 0.00412609 0.00499065 0.00597531 0.00708635 0.00833303 0.009726 0.0112768 0.0129974 0.0148996 0.0169955 0.0192964 0.0218127 0.0245532 0.0275226 0.000346207 0.000476741 0.000743315 0.000985405 0.00122481 0.00147813 0.00177136 0.00217409 0.00270945 0.00335198 0.00409963 0.00495833 0.00593697 0.00704154 0.0082812 0.00966654 0.0112091 0.0129207 0.0148134 0.016899 0.019189 0.0216937 0.0244214 0.0273782 0.000346611 0.000477586 0.000745085 0.000987916 0.00122773 0.00148077 0.0017718 0.00216519 0.00269427 0.00333148 0.00407378 0.0049268 0.00589943 0.00699766 0.00823043 0.0096083 0.0111427 0.0128456 0.0147288 0.0168044 0.0190836 0.0215767 0.0242923 0.0272379 0.000347012 0.00047846 0.0007469 0.000990503 0.00123075 0.00148348 0.00177231 0.00215668 0.00267955 0.00331149 0.00404855 0.00489603 0.0058627 0.00695472 0.00818071 0.00955122 0.0110777 0.012772 0.0146459 0.0167115 0.0189801 0.0214618 0.0241652 0.0270965 0.000347451 0.000479384 0.000748756 0.000993136 0.00123381 0.00148618 0.00177279 0.00214852 0.00266528 0.00329201 0.00402393 0.00486598 0.00582678 0.00691263 0.008132 0.0094953 0.011014 0.0126997 0.0145645 0.0166204 0.0188785 0.0213493 0.0240421 0.0269677 0.000347911 0.000480307 0.000750647 0.000995797 0.00123683 0.00148879 0.00177319 0.00214066 0.00265139 0.00327303 0.00399992 0.00483663 0.00579161 0.0068714 0.00808424 0.00944048 0.0109515 0.0126289 0.0144847 0.016531 0.018779 0.0212392 0.0239217 0.0268368 0.000348344 0.000481192 0.000752509 0.000998411 0.00123981 0.00149131 0.00177346 0.00213313 0.00263792 0.00325454 0.00397647 0.00480791 0.00575716 0.006831 0.00803745 0.00938676 0.0108903 0.0125596 0.0144068 0.0164435 0.0186814 0.0211312 0.023803 0.0267046 0.000348764 0.00048206 0.000754326 0.00100096 0.00124268 0.00149367 0.00177362 0.00212597 0.00262485 0.00323651 0.00395356 0.00477983 0.00572343 0.00679142 0.00799159 0.00933408 0.0108302 0.0124916 0.0143301 0.0163575 0.0185856 0.021025 0.0236859 0.0265744 0.00034922 0.000482963 0.000756126 0.00100346 0.00124545 0.00149591 0.00177372 0.00211928 0.00261218 0.00321893 0.00393116 0.00475233 0.00569037 0.00675263 0.00794664 0.00928243 0.0107712 0.0124248 0.0142548 0.0162732 0.0184917 0.0209212 0.0235714 0.0264508 0.000349692 0.000483839 0.000757883 0.00100587 0.0012481 0.00149802 0.00177381 0.00211319 0.00259992 0.00320177 0.00390927 0.00472545 0.00565806 0.00671462 0.00790257 0.00923181 0.0107135 0.0123592 0.0141809 0.0161904 0.0183995 0.0208195 0.0234608 0.0263366 0.000350149 0.000484685 0.000759573 0.0010082 0.00125065 0.00150006 0.00177399 0.00210785 0.00258811 0.00318507 0.00388788 0.00469915 0.00562636 0.00667735 0.00785935 0.00918215 0.0106568 0.0122949 0.0141084 0.0161091 0.0183092 0.0207197 0.0233515 0.0262139 0.000350588 0.000485478 0.000761206 0.00101045 0.00125312 0.00150207 0.00177434 0.00210344 0.00257685 0.00316881 0.00386698 0.00467337 0.00559529 0.00664083 0.00781697 0.00913343 0.0106012 0.0122318 0.0140373 0.0160297 0.0182207 0.0206218 0.0232433 0.0260929 0.000351017 0.000486265 0.000762792 0.00101263 0.00125553 0.00150412 0.001775 0.00210003 0.00256612 0.00315301 0.00384655 0.00464814 0.00556485 0.00660504 0.00777543 0.00908565 0.0105466 0.01217 0.0139676 0.0159517 0.0181339 0.0205257 0.0231378 0.0259812 0.000351482 0.000487081 0.00076436 0.00101478 0.00125795 0.00150629 0.00177603 0.00209763 0.00255597 0.00313767 0.00382661 0.00462349 0.00553503 0.00657001 0.00773476 0.00903881 0.0104932 0.0121093 0.0138993 0.0158751 0.0180487 0.0204314 0.0230339 0.025865 0.000351964 0.000487874 0.000765905 0.00101691 0.00126039 0.0015086 0.00177745 0.00209612 0.00254639 0.00312278 0.00380714 0.00459933 0.00550582 0.00653564 0.00769486 0.00899289 0.0104408 0.0120499 0.0138323 0.0158001 0.0179651 0.0203389 0.0229321 0.025755 0.000352435 0.000488653 0.000767421 0.00101904 0.00126289 0.00151108 0.00177923 0.00209533 0.00253737 0.00310836 0.00378812 0.00457568 0.00547722 0.00650193 0.00765572 0.00894788 0.0103894 0.0119916 0.0137666 0.0157266 0.0178833 0.0202485 0.0228337 0.0256518 0.00035289 0.000489384 0.000768926 0.00102119 0.00126547 0.00151374 0.00178134 0.00209511 0.00252887 0.00309441 0.00376959 0.00455259 0.00544931 0.0064689 0.00761734 0.00890376 0.0103392 0.0119347 0.0137023 0.0156546 0.0178033 0.0201606 0.0227392 0.0255554 0.000353357 0.000490196 0.000770483 0.00102338 0.00126815 0.00151658 0.00178371 0.00209528 0.00252084 0.0030809 0.0037515 0.00452999 0.00542201 0.00643658 0.00757991 0.00886065 0.0102898 0.0118788 0.0136393 0.0155841 0.0177252 0.0200751 0.0226476 0.0254589 0.000353859 0.000490998 0.000772042 0.00102562 0.00127091 0.00151955 0.00178625 0.00209571 0.00251322 0.00306781 0.00373388 0.00450795 0.00539534 0.00640492 0.00754314 0.00881849 0.0102416 0.011824 0.0135777 0.0155153 0.0176488 0.0199914 0.0225562 0.0253531 0.00035436 0.000491796 0.000773617 0.0010279 0.00127373 0.0015226 0.0017889 0.00209626 0.00250595 0.00305513 0.00371677 0.00448649 0.00536926 0.00637394 0.00750708 0.00877705 0.0101943 0.0117705 0.0135175 0.0154479 0.0175741 0.019909 0.0224646 0.0252474 0.00035485 0.000492577 0.000775199 0.0010302 0.0012766 0.00152571 0.00179157 0.00209688 0.00249901 0.00304287 0.00370011 0.00446564 0.00534389 0.00634359 0.00747176 0.00873643 0.010148 0.011718 0.0134585 0.0153819 0.0175008 0.0198281 0.0223756 0.0251531 0.000355337 0.000493358 0.000776786 0.00103252 0.0012795 0.00152884 0.00179424 0.00209751 0.00249237 0.00303097 0.00368383 0.00444518 0.00531917 0.00631405 0.00743718 0.00869665 0.0101026 0.0116665 0.0134006 0.0153173 0.0174295 0.0197501 0.0222928 0.0250804 0.000355867 0.000494195 0.000778408 0.00103487 0.00128242 0.00153196 0.00179688 0.0020981 0.00248598 0.00301938 0.00366796 0.00442516 0.00529485 0.00628505 0.00740333 0.0086577 0.0100581 0.0116162 0.0133441 0.0152542 0.0173598 0.0196743 0.0222123 0.024992 0.000356422 0.000495033 0.000780042 0.00103723 0.00128531 0.00153505 0.00179945 0.00209867 0.00247989 0.00300813 0.00365249 0.00440561 0.00527105 0.00625665 0.0073702 0.00861957 0.0100147 0.011567 0.0132888 0.0151928 0.017292 0.0196001 0.0221309 0.0248937 0.000356936 0.000495802 0.000781627 0.00103954 0.00128817 0.00153805 0.00180193 0.00209919 0.00247422 0.00299735 0.00363743 0.00438652 0.00524777 0.00622883 0.00733777 0.00858227 0.00997213 0.0115189 0.0132348 0.0151327 0.0172256 0.0195268 0.0220484 0.0247948 0.000357429 0.000496569 0.000783197 0.00104182 0.00129097 0.00154103 0.00180436 0.00209965 0.0024688 0.00298685 0.00362275 0.00436788 0.00522503 0.0062018 0.00730621 0.00854579 0.00993055 0.0114718 0.013182 0.0150739 0.0171604 0.0194545 0.0219678 0.0247104 0.000357959 0.000497372 0.000784772 0.00104408 0.00129376 0.00154394 0.00180668 0.0021001 0.00246378 0.00297667 0.00360846 0.0043497 0.0052028 0.00617526 0.00727526 0.00851013 0.0098899 0.0114259 0.0131304 0.0150163 0.0170964 0.0193831 0.0218869 0.0246117 0.000358539 0.000498222 0.00078636 0.00104632 0.00129646 0.00154674 0.00180894 0.00210062 0.00245927 0.00296687 0.00359457 0.00433197 0.0051811 0.0061493 0.00724499 0.00847528 0.00985019 0.011381 0.01308 0.0149599 0.0170335 0.0193128 0.0218083 0.0245298 0.000359143 0.000499035 0.000787851 0.00104846 0.0012991 0.00154948 0.00181117 0.00210123 0.00245534 0.00295745 0.00358105 0.00431469 0.00515992 0.00612394 0.00721538 0.00844121 0.00981137 0.0113371 0.0130307 0.0149047 0.0169718 0.0192437 0.0217305 0.0244389 0.000359729 0.000499832 0.000789446 0.00105067 0.00130168 0.00155217 0.0018134 0.00210202 0.00245208 0.00294859 0.00356808 0.00429786 0.00513926 0.00609919 0.00718664 0.00840813 0.00977366 0.0112944 0.0129824 0.0148506 0.0169112 0.0191756 0.0216539 0.0243533 0.000360226 0.000500453 0.000790914 0.00105276 0.0013042 0.00155481 0.00181566 0.00210301 0.0024495 0.00294008 0.00355541 0.00428144 0.0051191 0.00607502 0.00715848 0.00837572 0.0097367 0.0112526 0.0129352 0.0147976 0.0168517 0.0191086 0.0215778 0.0242643 0.000360692 0.000501184 0.000792348 0.00105481 0.00130669 0.00155745 0.001818 0.00210426 0.00244761 0.00293204 0.00354328 0.00426563 0.00509948 0.0060515 0.007131 0.00834423 0.00970076 0.0112117 0.0128893 0.0147458 0.0167932 0.0190424 0.0215021 0.0241753 0.000361278 0.000501952 0.000793778 0.00105682 0.00130916 0.00156012 0.00182044 0.00210577 0.00244639 0.00292447 0.00353147 0.00425017 0.00508038 0.00602865 0.00710421 0.00831342 0.00966561 0.0111719 0.0128443 0.014695 0.0167357 0.0189772 0.0214279 0.0240925 0.000362053 0.000502943 0.000795233 0.00105894 0.00131173 0.00156284 0.00182309 0.00210773 0.00244583 0.00291737 0.00352009 0.00423531 0.00506196 0.00600645 0.00707812 0.00828335 0.00963127 0.0111329 0.0128003 0.0146451 0.0166794 0.0189133 0.0213555 0.024013 0.000362973 0.000503954 0.000796792 0.00106101 0.00131426 0.00156563 0.00182585 0.00210986 0.00244574 0.00291074 0.00350913 0.00422083 0.00504417 0.00598504 0.00705275 0.00825406 0.00959778 0.0110949 0.0127571 0.0145963 0.016624 0.0188507 0.0212848 0.0239333 0.000363691 0.00050477 0.000798282 0.00106307 0.0013168 0.00156848 0.00182872 0.00211219 0.00244605 0.00290458 0.00349862 0.0042068 0.0050268 0.00596416 0.00702807 0.00822553 0.00956514 0.0110577 0.0127149 0.0145484 0.0165698 0.0187894 0.0212158 0.023857 0.000364377 0.000505561 0.000799739 0.00106513 0.00131936 0.0015714 0.00183171 0.0021147 0.00244665 0.00289879 0.00348854 0.00419324 0.00500994 0.00594388 0.00700409 0.00819778 0.00953334 0.0110215 0.0126737 0.0145018 0.0165169 0.0187295 0.0211494 0.0237873 0.000365079 0.000506367 0.000801198 0.00106721 0.00132205 0.00157444 0.00183479 0.00211738 0.0024476 0.00289349 0.00347889 0.00418015 0.00499361 0.00592418 0.00698078 0.00817079 0.00950238 0.0109861 0.0126335 0.0144561 0.0164652 0.0186713 0.0210843 0.0237131 0.000365803 0.000507179 0.000802659 0.00106929 0.00132472 0.00157758 0.00183804 0.00212015 0.00244865 0.00288848 0.00346966 0.00416755 0.00497784 0.00590526 0.00695832 0.00814458 0.00947227 0.0109517 0.0125943 0.0144116 0.0164148 0.0186144 0.0210204 0.0236401 0.000366551 0.000508054 0.000804155 0.0010714 0.0013274 0.00158071 0.00184131 0.00212301 0.00244983 0.00288379 0.00346084 0.00415542 0.0049626 0.00588685 0.00693647 0.00811914 0.00944301 0.0109183 0.0125562 0.0143683 0.0163657 0.0185594 0.0209599 0.0235811 0.000367228 0.000508686 0.00080556 0.00107347 0.00133007 0.00158381 0.00184456 0.00212591 0.00245107 0.00287936 0.00345242 0.00414377 0.0049479 0.00586903 0.00691528 0.00809448 0.00941463 0.0108858 0.0125191 0.0143262 0.0163182 0.0185063 0.0209018 0.023518 0.000367804 0.00050938 0.000806937 0.00107553 0.00133274 0.00158694 0.00184787 0.00212882 0.00245236 0.00287521 0.00344437 0.00413257 0.00493374 0.00585182 0.00689477 0.00807059 0.0093871 0.0108542 0.0124832 0.0142854 0.0162722 0.0184549 0.0208447 0.0234511 0.000368543 0.00051025 0.000808514 0.00107772 0.00133545 0.0015901 0.00185118 0.00213176 0.00245376 0.00287154 0.00343687 0.00412188 0.00492015 0.00583526 0.00687515 0.00804769 0.00936067 0.0108239 0.0124484 0.0142459 0.0162277 0.018405 0.0207885 0.0233853 0.000369382 0.000511173 0.00081009 0.0010799 0.00133819 0.00159328 0.00185451 0.00213471 0.00245519 0.00286804 0.00342968 0.00411166 0.00490714 0.00581935 0.00685615 0.0080255 0.00933505 0.0107945 0.0124148 0.0142078 0.0161847 0.0183565 0.0207334 0.0233217 0.000370254 0.000512073 0.000811651 0.00108207 0.00134092 0.00159645 0.00185782 0.00213765 0.00245668 0.00286486 0.003423 0.00410205 0.0048947 0.00580412 0.00683791 0.0080043 0.00931051 0.0107662 0.0123827 0.0141712 0.0161431 0.0183095 0.0206804 0.0232636 0.000371309 0.0005132 0.000813238 0.00108435 0.00134375 0.00159963 0.0018612 0.00214064 0.00245819 0.00286197 0.00341666 0.00409301 0.00488296 0.00578955 0.00682043 0.00798388 0.00928691 0.0107392 0.0123518 0.014136 0.0161031 0.0182645 0.020631 0.023217 0.000372532 0.000514358 0.000814936 0.00108658 0.00134653 0.00160279 0.00186452 0.00214366 0.00245984 0.00285941 0.00341071 0.00408438 0.00487191 0.00577584 0.00680377 0.00796435 0.00926428 0.0107132 0.0123221 0.0141021 0.0160649 0.0182218 0.0205839 0.023162 0.000373568 0.000515329 0.000816568 0.00108881 0.0013493 0.00160595 0.00186782 0.00214663 0.00246151 0.0028572 0.00340519 0.00407625 0.00486137 0.00576278 0.00678796 0.00794582 0.00924275 0.0106884 0.0122938 0.0140699 0.0160285 0.0181813 0.0205402 0.023121 0.000374595 0.000516285 0.000818166 0.00109102 0.00135204 0.00160908 0.00187109 0.00214957 0.00246324 0.00285535 0.00340013 0.00406866 0.00485144 0.00575045 0.00677304 0.00792824 0.00922235 0.010665 0.0122669 0.0140393 0.015994 0.0181432 0.0204991 0.023076 0.000375664 0.000517261 0.000819756 0.0010932 0.00135475 0.00161219 0.00187434 0.00215251 0.00246504 0.00285388 0.00339554 0.00406164 0.00484219 0.00573891 0.00675904 0.00791173 0.00920315 0.0106428 0.0122416 0.0140106 0.0159618 0.0181073 0.0204595 0.0230288 0.000376784 0.000518262 0.000821353 0.00109539 0.00135754 0.00161534 0.00187757 0.00215548 0.00246705 0.00285291 0.00339146 0.00405523 0.00483366 0.00572818 0.00674597 0.00789632 0.00918521 0.0106221 0.0122178 0.0139837 0.0159315 0.0180735 0.0204212 0.0229832 0.000377957 0.000519289 0.000822958 0.00109756 0.00136027 0.00161853 0.00188087 0.00215847 0.00246914 0.00285233 0.0033879 0.00404946 0.00482589 0.00571851 0.00673409 0.00788209 0.00916861 0.010603 0.0121958 0.0139587 0.0159033 0.0180416 0.0203843 0.0229381 0.000379186 0.000520326 0.000824563 0.00109973 0.00136296 0.00162164 0.00188414 0.00216152 0.00247137 0.00285216 0.0033849 0.00404437 0.00481892 0.00570968 0.00672327 0.00786912 0.00915344 0.0105854 0.0121757 0.0139357 0.0158772 0.0180118 0.02035 0.0228994 0.000380482 0.000521455 0.000826213 0.00110191 0.00136565 0.00162473 0.00188742 0.00216465 0.00247378 0.00285245 0.0033825 0.00404001 0.00481283 0.00570186 0.00671363 0.00785751 0.00913981 0.0105696 0.0121574 0.0139148 0.0158534 0.0179847 0.02032 0.0228741 0.00038171 0.000522255 0.000827708 0.001104 0.00136829 0.00162779 0.0018907 0.00216784 0.00247636 0.00285318 0.00338071 0.00403642 0.00480766 0.00569514 0.00670524 0.00784734 0.00912779 0.0105556 0.0121412 0.0138962 0.015832 0.0179603 0.0202921 0.0228357 0.000382917 0.000523267 0.000829357 0.00110618 0.00137092 0.00163086 0.00189401 0.00217112 0.00247915 0.00285449 0.00337969 0.00403366 0.00480352 0.00568963 0.00669842 0.00783892 0.00911774 0.0105437 0.0121273 0.01388 0.0158133 0.0179387 0.0202675 0.0228106 0.0003844 0.000524443 0.000831044 0.00110837 0.00137361 0.00163399 0.00189742 0.00217455 0.00248218 0.00285625 0.0033795 0.00403198 0.00480051 0.00568542 0.006693 0.0078321 0.00910949 0.0105339 0.0121157 0.0138664 0.0157974 0.0179203 0.0202462 0.0227851 0.000386015 0.000525652 0.000832754 0.00111057 0.00137634 0.00163717 0.00190089 0.00217809 0.00248546 0.00285852 0.00338 0.00403123 0.00479871 0.00568267 0.00668923 0.0078273 0.00910349 0.0105265 0.0121068 0.0138557 0.0157846 0.0179052 0.0202287 0.0227657 0.0003879 0.000527122 0.000834524 0.00111293 0.00137919 0.00164043 0.00190456 0.00218195 0.00248909 0.00286133 0.00338137 0.00403173 0.0047984 0.00568151 0.00668728 0.00782448 0.00909977 0.0105217 0.0121008 0.0138481 0.0157752 0.017894 0.020217 0.0227609 0.000390104 0.000528708 0.00083645 0.00111528 0.00138207 0.00164376 0.0019083 0.00218591 0.00249297 0.00286473 0.00338371 0.00403341 0.00479969 0.00568226 0.00668738 0.00782394 0.00909855 0.0105197 0.0120978 0.0138439 0.0157697 0.0178869 0.0202066 0.0227321 0.00039224 0.000530105 0.000838358 0.00111768 0.00138501 0.00164721 0.00191217 0.00219004 0.00249717 0.00286878 0.00338719 0.00403649 0.00480257 0.00568495 0.00668977 0.00782598 0.0091002 0.0105209 0.0120983 0.0138434 0.015768 0.0178842 0.0202036 0.0227445 0.000394455 0.000531533 0.000840295 0.00112015 0.00138804 0.00165079 0.00191621 0.00219441 0.00250172 0.00287355 0.0033919 0.0040412 0.00480739 0.00568989 0.00669478 0.00783096 0.0091051 0.0105256 0.0121026 0.013847 0.0157708 0.0178854 0.0202 0.0227102 0.000396872 0.000533053 0.000842296 0.0011227 0.00139118 0.00165452 0.00192046 0.00219905 0.00250669 0.00287912 0.00339807 0.00404782 0.00481449 0.00569747 0.00670279 0.0078393 0.0091137 0.0105343 0.0121112 0.0138553 0.0157783 0.017891 0.0202028 0.0227238 0.000399548 0.00053469 0.000844406 0.00112538 0.00139457 0.00165853 0.00192497 0.00220405 0.00251226 0.00288578 0.00340597 0.00405668 0.00482426 0.00570811 0.00671427 0.00785152 0.00912654 0.0105476 0.0121246 0.0138686 0.0157908 0.0179016 0.0202094 0.0227165 0.000402539 0.000536463 0.000846655 0.00112822 0.00139814 0.00166285 0.00192989 0.00220947 0.00251841 0.00289365 0.00341597 0.00406825 0.00483724 0.00572258 0.00673001 0.00786827 0.00914429 0.0105661 0.0121436 0.0138876 0.015809 0.0179176 0.0202208 0.0227221 0.000405932 0.000538396 0.000849099 0.0011313 0.00140198 0.00166748 0.00193523 0.00221548 0.00252538 0.00290314 0.0034286 0.00408315 0.00485413 0.00574137 0.00675058 0.00789039 0.00916778 0.0105907 0.0121688 0.0139129 0.0158335 0.0179403 0.0202432 0.0227629 0.000409828 0.000540553 0.000851748 0.00113465 0.00140618 0.00167256 0.00194113 0.0022222 0.0025334 0.00291474 0.00344446 0.00410209 0.00487574 0.00576549 0.00677704 0.00791885 0.00919799 0.0106222 0.0122012 0.0139454 0.0158653 0.0179713 0.0202758 0.0228003 0.00041438 0.000543015 0.000855113 0.00113887 0.00141139 0.00167878 0.0019483 0.00223039 0.0025434 0.00293013 0.00346552 0.00412718 0.00490418 0.00579695 0.00681118 0.00795537 0.00923645 0.0106621 0.0122419 0.0139863 0.0159056 0.0180109 0.0203148 0.0228284 0.000419119 0.000543609 0.000856533 0.00114162 0.00141543 0.00168406 0.0019547 0.00223796 0.00255317 0.00294635 0.00348835 0.00415497 0.00493634 0.00583314 0.00685118 0.00799863 0.00928242 0.0107101 0.0122911 0.0140358 0.0159549 0.0180596 0.020363 0.0228819 0.000435005 0.00056051 0.000872701 0.00115772 0.00143267 0.00170288 0.00197528 0.00226083 0.00258118 0.00299077 0.0035438 0.00421737 0.0050037 0.00590401 0.00692431 0.00807288 0.00935639 0.0107827 0.0123613 0.014103 0.0160187 0.0181203 0.020421 0.0229344 0.000310097 0.000483763 0.000827873 0.00112052 0.00139793 0.0016683 0.00193822 0.00221854 0.00253265 0.00293392 0.00348349 0.0041554 0.0049413 0.00584292 0.00686651 0.00802027 0.00931136 0.0107471 0.0123372 0.0140921 0.0160226 0.0181407 0.0204599 0.0229943 0.102085 0.0313564 0.139424 0.0596728 0.137841 0.114335 0.0935445 0.055841 0.0535677 0.120081 0.0820267 0.130968 0.0520954 0.133987 0.0284572 0.0831184 0.0444405 0.125002 0.101207 0.139863 0.0847146 0.111346 0.132663 0.0386145 0.114982 0.107015 0.136597 0.0255222 0.0347887 0.121185 0.0734174 0.130381 0.138285 0.133308 0.139937 0.138838 0.097416 0.0957541 0.109387 0.137369 0.100373 0.101481 0.130165 0.11551 0.137427 0.0810184 0.121302 0.260096 0.146399 0.0878067 0.0758744 0.127888 0.136166 0.0700983 0.0740931 0.137424 0.140116 0.0594139 0.100609 0.105145 0.0662138 0.135105 0.139883 0.078479 0.032459 0.0752054 0.0871588 0.174484 0.0676531 0.0738837 0.139901 0.0895431 0.0288657 0.0908433 0.0316532 0.0935971 0.104315 0.320332 0.135073 0.13142 0.0837927 0.0687602 0.0292251 0.0976216 0.0644756 0.0932582 0.0787031 0.140163 0.043622 0.136661 0.140066 0.122675 0.12069 0.0294757 0.0253422 0.134833 0.145867 0.0260598 0.0974455 0.131352 0.0788328 0.0592667 0.138283 0.0670727 0.123186 0.125525 0.0897229 0.0430036 0.0425044 0.0891944 0.117886 0.137157 0.0810938 0.15494 0.0728374 0.138722 0.0508023 0.138406 0.118667 0.0891283 0.0673753 0.102413 0.141563 0.0806961 0.0926736 0.0734104 0.10158 0.0815971 0.0648492 0.124043 0.121891 0.0539919 0.104977 0.137726 0.122069 0.0567871 0.0436231 0.137444 0.0601945 0.113718 0.140801 0.140104 0.137401 0.114746 0.140036 0.111445 0.0823052 0.038961 0.125901 0.109136 0.111721 0.137122 0.0772668 0.0993842 0.0681363 0.0346092 0.0300078 0.0573179 0.0863269 0.0275103 0.108733 0.134753 0.136622 0.100223 0.129455 0.0481682 0.141641 0.0677599 0.0698754 0.0974844 0.0627845 0.112742 0.0899081 0.195952 0.107532 0.13657 0.136881 0.0470025 0.10235 0.0356249 0.0743087 0.097031 0.20898 0.0799488 0.0858942 0.134672 0.0377001 0.139334 0.0703347 0.12555 0.0360594 0.137483 0.113734 0.136478 0.0334318 0.116638 0.0896789 0.139765 0.131098 0.0969496 0.137091 0.0827148 0.0506622 0.135473 0.0581323 0.0639524 0.0749102 0.106722 0.0724062 0.0405309 0.1354 0.127527 0.113517 0.0717075 0.0812625 0.0282127 0.0577992 0.0730824 0.0363505 0.076156 0.12498 0.107469 0.118815 0.137799 0.134497 0.0820493 0.109246 0.0789467 0.139034 0.103686 0.245157 0.117713 0.0998571 0.111497 0.135909 0.136293 0.140138 0.0379873 0.061128 0.108634 0.0265959 0.0700217 0.0783909 0.0364852 0.0425073 0.0659792 0.0333137 0.128639 0.116834 0.072248 0.13905 0.132427 0.119033 0.0771819 0.140153 0.0376792 0.109379 0.0890594 0.117192 0.0739934 0.112173 0.0955203 0.107759 0.0613998 0.123449 0.140139 0.0338179 0.069415 0.0793046 0.0373013 0.049718 0.116737 0.0719292 0.0844026 0.135306 0.089474 0.138492 0.136993 0.102034 0.0860376 0.113178 0.0569243 0.0822996 0.12336 0.05625 0.0385205 0.103944 0.13982 0.13827 0.124953 0.0376512 0.0547927 0.103082 0.0432978 0.139868 0.0603093 0.130691 0.142615 0.134358 0.108361 0.0995039 0.127521 0.11102 0.138575 0.125054 0.107196 0.0440885 0.105021 0.3165 0.0752116 0.112052 0.0824034 0.138549 0.0897381 0.148991 0.0829515 0.139033 0.139168 0.139622 0.0486475 0.136392 0.125499 0.115466 0.123903 0.0634 0.126572 0.106189 0.0423812 0.025656 0.133422 0.129686 0.0966234 0.117639 0.104952 0.102033 0.101914 0.0880884 0.135967 0.132426 0.131726 0.093443 0.12972 0.131842 0.134239 0.11687 0.101419 0.110846 0.118076 0.0482265 0.140187 0.0733236 0.041745 0.104037 0.0862868 0.132032 0.137136 0.111573 0.130126 0.0931884 0.0962059 0.132676 0.0647422 0.115826 0.130925 0.0757448 0.0460263 0.111038 0.110152 0.0843917 0.139772 0.146381 0.0879391 0.131854 0.0915263 0.138475 0.156566 0.125439 0.0322312 0.128768 0.0498446 0.139997 0.0910835 0.11445 0.138937 0.136813 0.0656157 0.143274 0.0360274 0.0362984 0.063117 0.120995 0.0940966 0.0953698 0.136444 0.140163 0.104766 0.0889137 0.0815642 0.0490894 0.0862773 0.0978906 0.109926 0.234853 0.13047 0.0842167 0.120655 0.137825 0.0888559 0.160582 0.139797 0.109013 0.129317 0.124916 0.114587 0.129914 0.0952121 0.0283143 0.110109 0.0651509 0.103229 0.0850193 0.0356719 0.0417688 0.113433 0.083597 0.134443 0.0451566 0.125868 0.132111 0.117521 0.0945154 0.125268 0.0815306 0.139564 0.0889453 0.061482 0.136475 0.0378433 0.0740431 0.0821101 0.139017 0.0335103 0.0395755 0.0711564 0.0917349 0.0693134 0.138308 0.0601145 0.139962 0.105972 0.101096 0.0325626 0.0558671 0.138742 0.109469 0.107838 0.222202 0.122584 0.139001 0.109592 0.139529 0.10583 0.0662067 0.0717334 0.0462436 0.057034 0.137586 0.051975 0.0187638 0.0909287 0.139318 0.0945465 0.104823 0.129318 0.0773122 0.0732222 0.101154 0.120036 0.125861 0.107503 0.0847335 0.0721484 0.0787092 0.0625134 0.12213 0.127338 0.150231 0.224327 0.0949118 0.0619529 0.0497944 0.0921524 0.115397 0.116401 0.132927 0.138276 0.138993 0.0541673 0.140141 0.100149 0.0724607 0.0855042 0.0692262 0.0919382 0.342469 0.129241 0.123272 0.0282117 0.079788 0.135785 0.0578309 0.0316474 0.0903711 0.0582425 0.12867 0.136939 0.0924763 0.139255 0.0357409 0.12072 0.124289 0.13067 0.105523 0.0374581 0.0367994 0.139546 0.138955 0.14546 0.133439 0.13769 0.115137 0.131255 0.0675008 0.0700181 0.136742 0.0597669 0.0788963 0.0983079 0.138475 0.0588765 0.0835927 0.139103 0.0974472 0.101541 0.306947 0.0766004 0.280639 0.108257 0.125321 0.100399 0.147417 0.0869049 0.0287229 0.140166 0.0765441 0.0577071 0.0988964 0.0884408 0.0763938 0.0693719 0.139614 0.116974 0.0511122 0.131143 0.139783 0.129213 0.139095 0.126919 0.138724 0.140212 0.121346 0.0411042 0.130155 0.104474 0.0399366 0.138469 0.0250306 0.139444 0.0962553 0.104843 0.0325351 0.00459395 0.129942 0.0256072 0.079943 0.0598801 0.080102 0.0752213 0.109679 0.0749287 0.092291 0.123361 0.0843398 0.0298953 0.0839151 0.106067 0.0382899 0.125105 0.0786032 0.0829006 0.138148 0.076886 0.140071 0.0516525 0.0510847 0.073963 0.0815275 0.0477052 0.0680069 0.136646 0.0257575 0.138661 0.134502 0.137731 0.0368463 0.273885 0.0803773 0.0370997 0.0353314 0.124513 0.0645839 0.147768 0.136573 0.162263 0.13995 0.128273 0.12653 0.0549206 0.118002 0.0302295 0.0752371 0.138736 0.0925592 0.136373 0.0749332 0.0804762 0.0932506 0.126183 0.139515 0.0923616 0.102645 0.137741 0.0743767 0.121913 0.119047 0.118772 0.138554 0.138829 0.0931719 0.140032 0.0786357 0.136747 0.111891 0.104821 0.0944722 0.100799 0.0887803 0.137223 0.136578 0.0741437 0.139428 0.0769918 0.117482 0.0279232 0.0788024 0.138425 0.131774 0.121975 0.10678 0.101442 0.0402169 0.136931 0.140171 0.0387536 0.0866077 0.0803948 0.132037 0.0625668 0.00566973 0.0874859 0.1328 0.0497826 0.0660807 0.0867019 0.132777 0.13108 0.08481 0.137497 0.132023 0.136922 0.135537 0.121079 0.140069 0.0317228 0.044737 0.121089 0.102387 0.0862389 0.134279 0.0808257 0.124019 0.0855888 0.0706386 0.096786 0.0517133 0.131087 0.0584055 0.136403 0.138856 0.0571295 0.0801501 0.0921551 0.0317844 0.129755 0.0676542 0.104254 0.124773 0.113205 0.0856919 0.096009 0.140146 0.111811 0.140094 0.0540302 0.0796819 0.08752 0.0392699 0.137849 0.0461014 0.0623356 0.0952146 0.0528658 0.139897 0.139053 0.0937192 0.0598942 0.0646663 0.125628 0.115881 0.129871 0.110501 0.0824479 0.0468426 0.108216 0.0652375 0.0610438 0.0926876 0.124805 0.110468 0.0815912 0.0319029 0.0924981 0.138698 0.102471 0.0455852 0.08817 0.105834 0.0503901 0.0903559 0.0741431 0.138414 0.115828 0.0474887 0.0439562 0.139621 0.139701 0.13154 0.13816 0.128486 0.140027 0.096433 0.0931077 0.0938215 0.133252 0.101005 0.0486298 0.137346 0.0844412 0.0813127 0.0376852 0.112352 0.140965 0.139207 0.13868 0.0727768 0.0928252 0.0779957 0.136429 0.120639 0.172702 0.00662509 0.139922 0.10075 0.0789122 0.136563 0.116411 0.043781 0.0730126 0.0135399 0.114953 0.0955238 0.0844238 0.0308866 0.0878274 0.0637039 0.0730598 0.0998688 0.12817 0.123797 0.153746 0.0903417 0.128115 0.136881 0.0663802 0.13883 0.0989493 0.0436212 0.0159784 0.0561533 0.136586 0.112546 0.0991513 0.109543 0.0659166 0.0499508 0.0303555 0.0797253 0.0270954 0.0968974 0.0806166 0.0708908 0.043267 0.116209 0.0599964 0.11729 0.131691 0.0477391 0.0383111 0.12406 0.106163 0.179155 0.0658114 0.136247 0.105485 0.0631618 0.139408 0.0763874 0.174206 0.140092 0.0431971 0.0708396 0.0782088 0.085989 0.117995 0.100952 0.0921211 0.137934 0.128433 0.0441814 0.111619 0.039721 0.137389 0.0458231 0.0470242 0.240284 0.083427 0.140014 0.136674 0.0590441 0.0828481 0.0811713 0.138275 0.105798 0.10437 0.096152 0.0798337 0.0929795 0.137166 0.121909 0.119563 0.0979747 0.131623 0.0560245 0.139913 0.123107 0.281371 0.0769513 0.102762 0.0340854 0.135708 0.129821 0.114113 0.0611529 0.096998 0.0800664 0.122609 0.056976 0.029335 0.0461907 0.137302 0.0409851 0.106759 0.139587 0.0916802 0.126182 0.132527 0.105311 0.0999962 0.0976902 0.137525 0.0590712 0.118794 0.0732855 0.137326 0.0841833 0.0665034 0.13685 0.0830008 0.0965206 0.125543 0.12548 0.0853039 0.0492128 0.133524 0.12215 0.122439 0.138422 0.138175 0.0472012 0.0661082 0.0934 0.140206 0.110711 0.107536 0.0634208 0.121272 0.075802 0.0972665 0.0561944 0.0446063 0.103168 0.0861943 0.138217 0.0877001 0.143196 0.111906 0.127208 0.113554 0.137216 0.0291215 0.259499 0.0713514 0.0280503 0.0269682 0.139815 0.0832469 0.070201 0.00508253 0.073089 0.0768177 0.0998324 0.13952 0.137389 0.126521 0.139412 0.0689437 0.362257 0.0867304 0.056025 0.0718632 0.126462 0.136101 0.0941547 0.0986403 0.137992 0.0491002 0.108095 0.0478638 0.0822158 0.139404 0.109252 0.0819598 0.0879749 0.0559646 0.0562491 0.139293 0.111987 0.0914653 0.0788835 0.107102 0.123011 0.155709 0.192906 0.090554 0.0583664 0.0684814 0.0754558 0.130342 0.136897 0.0722634 0.0261498 0.136443 0.0701277 0.0651327 0.0677372 0.0266122 0.0806695 0.0422841 0.136973 0.0651275 0.0914683 0.0509435 0.115257 0.0973843 0.0564981 0.0877477 0.0951604 0.119498 0.139843 0.0812082 0.116493 0.1073 0.0255842 0.049842 0.130462 0.10067 0.232116 0.100519 0.124833 0.112762 0.116036 0.109822 0.120237 0.0357816 0.0740877 0.139897 0.0360777 0.0957769 0.0277457 0.134925 0.0482725 0.135014 0.126802 0.0990261 0.0950277 0.130541 0.131718 0.0593606 0.140044 0.124069 0.0873994 0.0768174 0.0738783 0.0638172 0.0435339 0.106878 0.030235 0.0861638 0.127136 0.0368704 0.127544 0.0990909 0.0591069 0.116651 0.138744 0.0584009 0.139551 0.0934074 0.137086 0.130153 0.121977 0.0958817 0.0267188 0.0490692 0.140168 0.115706 0.139909 0.0948658 0.0178724 0.0581141 0.104674 0.0968784 0.0495894 0.0393457 0.0853633 0.0469121 0.20239 0.0769214 0.116178 0.139974 0.0688839 0.100644 0.130558 0.0769685 0.11896 0.0603473 0.0967256 0.138449 0.123558 0.0694372 0.139214 0.135579 0.0689765 0.115544 0.0367998 0.094173 0.124793 0.122696 0.0702352 0.0434501 0.104482 0.0727838 0.111348 0.0742578 0.110541 0.0813977 0.0721506 0.0960337 0.0436352 0.139304 0.104708 0.0553857 0.125484 0.133511 0.108521 0.135679 0.0302466 0.0366009 0.121759 0.0994511 0.072833 0.128261 0.0893862 0.0573916 0.122422 0.108206 0.0506812 0.0612885 0.0444147 0.104349 0.0904628 0.0322974 0.08466 0.0657829 0.136961 0.140117 0.119986 0.136191 0.0625739 0.0467854 0.131233 0.0602975 0.131265 0.0750146 0.0564961 0.140083 0.046089 0.1618 0.0769068 0.104758 0.119193 0.0662952 0.0835808 0.0256592 0.06002 0.0866592 0.0527897 0.116203 0.0450797 0.139863 0.123223 0.132729 0.0555878 0.137606 0.0772728 0.0907033 0.123152 0.107067 0.139736 0.0313039 0.0984429 0.0547282 0.139286 0.0369103 0.118326 0.0473115 0.0458325 0.0742314 0.0926241 0.139961 0.116757 0.133872 0.0791743 0.11062 0.137873 0.0881938 0.129777 0.139881 0.0607778 0.139312 0.0537304 0.122633 0.147748 0.111777 0.0360109 0.0257254 0.139782 0.139141 0.136788 0.0427384 0.092462 0.119455 0.13307 0.11614 0.130786 0.0802269 0.104178 0.110044 0.140169 0.113995 0.0451615 0.137397 0.0583924 0.0318964 0.134503 0.134241 0.0884974 0.0272431 0.127145 0.138343 0.0740886 0.138888 0.11102 0.0609683 0.0785398 0.118913 0.0701877 0.136216 0.146202 0.12835 0.0840472 0.0561524 0.044224 0.119665 0.0871977 0.170875 0.128392 0.100013 0.137448 0.0617185 0.121027 0.137152 0.0777316 0.0774746 0.0806422 0.0603177 0.0728179 0.132995 0.0965044 0.0995848 0.126004 0.119773 0.0719358 0.11339 0.122208 0.292035 0.138435 0.0352359 0.0682348 0.131041 0.0804177 0.0790357 0.0457435 0.0429868 0.140169 0.130965 0.0855415 0.102019 0.064246 0.0598272 0.104587 0.108913 0.0715139 0.0525038 0.17169 0.128966 0.0688395 0.0873894 0.13226 0.0991423 0.0547701 0.127716 0.138424 0.106732 0.0459181 0.0695772 0.116138 0.198959 0.126763 0.0891597 0.129999 0.114229 0.138257 0.0434389 0.11856 0.0473405 0.137751 0.0782502 0.0721983 0.118802 0.0788567 0.0588363 0.137995 0.125802 0.0604876 0.0432043 0.0146596 0.0924202 0.139798 0.130912 0.0708867 0.0846341 0.0661821 0.0887231 0.0828819 0.133504 0.137064 0.126602 0.0671566 0.0388657 0.116409 0.030447 0.130881 0.0418751 0.126772 0.135997 0.13217 0.138513 0.139914 0.0664552 0.0965569 0.113851 0.0499914 0.0463146 0.138094 0.128036 0.10328 0.0600951 0.114216 0.137759 0.0425776 0.0748901 0.128431 0.136993 0.13467 0.0444536 0.125272 0.135121 0.0434308 0.119588 0.0486023 0.13314 0.0659387 0.129129 0.139995 0.111213 0.127112 0.122978 0.130097 0.0710198 0.135152 0.123198 0.133639 0.0641968 0.118762 0.133711 0.0366323 0.113929 0.13935 0.110414 0.0398488 0.0430077 0.140094 0.138327 0.13893 0.0279479 0.0902847 0.132102 0.0558631 0.105842 0.136944 0.111974 0.120863 0.0451458 0.0534228 0.12039 0.132992 0.0650847 0.0548948 0.0905965 0.0713885 0.123664 0.100681 0.127216 0.107938 0.0908668 0.139088 0.130731 0.0767597 0.114471 0.144796 0.0782422 0.130453 0.138289 0.140085 0.057256 0.14004 0.137035 0.139152 0.118039 0.124587 0.107953 0.114428 0.033564 0.0475081 0.288293 0.0902565 0.0261584 0.0896929 0.0436454 0.133551 0.120687 0.0789297 0.1391 0.033017 0.0721888 0.11631 0.0781021 0.0855823 0.00709168 0.0874338 0.0937969 0.0369953 0.0203982 0.102784 0.107808 0.045025 0.051937 0.0397317 0.0614534 0.113914 0.0537539 0.0367977 0.0839706 0.0747425 0.0870491 0.0149815 0.0227648 0.120014 0.0780453 0.0682004 0.140164 0.139393 0.0654194 0.118758 0.073844 0.127427 0.108958 0.140187 0.114367 0.0772944 0.0256516 0.1392 0.112099 0.121149 0.0650131 0.106601 0.126472 0.109934 0.0596182 0.133052 0.139663 0.114337 0.111195 0.103979 0.084415 0.09488 0.0794089 0.114961 0.0457642 0.133812 0.109445 0.0687869 0.0928566 0.0659462 0.0652936 0.0842503 0.103307 0.134954 0.0789344 0.140375 0.141309 0.0750415 0.123122 0.0787177 0.110795 0.0478765 0.0935957 0.101757 0.141685 0.0752952 0.113597 0.0991174 0.103326 0.0786942 0.1136 0.127966 0.0901995 0.138762 0.140612 0.0822956 0.0734114 0.113684 0.125078 0.0747005 0.0984301 0.0792808 0.140007 0.088858 0.135775 0.137127 0.0567147 0.135524 0.0755895 0.132811 0.0696695 0.120949 0.100875 0.139221 0.12575 0.110806 0.080901 0.133433 0.12699 0.102575 0.0667527 0.0571681 0.0577914 0.137239 0.123542 0.120588 0.125996 0.0593639 0.0450834 0.0848772 0.132285 0.0842705 0.283197 0.340468 0.0863333 0.0386159 0.0531564 0.10843 0.0669833 0.107345 0.137726 0.0829586 0.13799 0.122909 0.111816 0.0930731 0.0579736 0.0778218 0.0868975 0.0910972 0.0849512 0.138606 0.0519722 0.139931 0.0256544 0.0556797 0.0107712 0.1391 0.078973 0.108887 0.167159 0.108703 0.124954 0.0839542 0.108322 0.112688 0.0939586 0.0946969 0.0664069 0.106797 0.131253 0.0458397 0.10913 0.0927646 0.0369311 0.092634 0.0620835 0.0535614 0.110185 0.0346858 0.0850007 0.0346313 0.0879583 0.133947 0.0994308 0.139214 0.0940638 0.12001 0.113218 0.0776324 0.0663712 0.046134 0.1039 0.0276852 0.105343 0.139988 0.0312497 0.0535383 0.0892271 0.0657153 0.0285556 0.137283 0.0856478 0.139488 0.138772 0.0328846 0.100656 0.138222 0.0303629 0.0908013 0.13983 0.0562678 0.139726 0.0756215 0.32365 0.0253372 0.106913 0.0512318 0.0988378 0.0681169 0.121476 0.0967536 0.0920642 0.0992545 0.0629476 0.0782631 0.120629 0.0841136 0.0984979 0.0956973 0.118855 0.113762 0.111809 0.139675 0.0306069 0.114879 0.104942 0.131919 0.036688 0.0464534 0.0283785 0.113463 0.0338146 0.0684612 0.0755149 0.0384101 0.101949 0.114955 0.116002 0.100769 0.10268 0.0294415 0.101739 0.0875449 0.0581852 0.180472 0.0780037 0.074573 0.126838 0.0843928 0.0270169 0.104476 0.0956483 0.138913 0.140036 0.0411265 0.0408169 0.0761685 0.131983 0.121303 0.123273 0.10448 0.0918471 0.101669 0.102967 0.110595 0.0996178 0.0906092 0.135669 0.139506 0.0297919 0.0152601 0.138887 0.137176 0.139731 0.0806824 0.140092 0.113107 0.0663595 0.0738059 0.133714 0.111684 0.0139008 0.0334896 0.0674626 0.104885 0.0756716 0.0677585 0.127733 0.139938 0.0422119 0.0431317 0.136361 0.109079 0.0846492 0.125772 0.136052 0.0736648 0.0934509 0.13194 0.140052 0.0554764 0.129915 0.0962988 0.0922238 0.0914423 0.00613465 0.032025 0.0584113 0.139623 0.139811 0.139963 0.0332814 0.0622447 0.139931 0.139783 0.134738 0.130628 0.132105 0.0490235 0.0384278 0.124781 0.131808 0.101082 0.120503 0.062673 0.0936264 0.0944351 0.136126 0.139135 0.0911351 0.0316521 0.121066 0.0288863 0.140004 0.139834 0.137771 0.139873 0.128128 0.0859911 0.0507787 0.101263 0.0800459 0.086669 0.118088 0.162036 0.0493747 0.0491726 0.118437 0.138981 0.0280606 0.0561378 0.0639238 0.087977 0.135556 0.129744 0.137781 0.0620043 0.114892 0.0822671 0.140191 0.0526859 0.108439 0.0847117 0.131894 0.127177 0.118819 0.0404883 0.0894421 0.0410497 0.0737778 0.0429482 0.0595975 0.140181 0.0423906 0.0941067 0.0981212 0.111385 0.085642 0.108917 0.136237 0.0973552 0.0880833 0.0411447 0.106685 0.0619615 0.104398 0.0937753 0.131125 0.108267 0.06184 0.0513366 0.0822964 0.0282323 0.139131 0.0823236 0.0430958 0.0287726 0.033 0.0726355 0.085391 0.0766977 0.0767499 0.378513 0.138309 0.0631021 0.0564647 0.0779969 0.0769619 0.0472188 0.124086 0.139103 0.0410983 0.0401755 0.123458 0.139286 0.0418376 0.0848903 0.0390355 0.0918325 0.0403143 0.139233 0.101522 0.0586352 0.126784 0.0928951 0.117898 0.0460473 0.091027 0.0930503 0.136152 0.133756 0.139746 0.0845939 0.0875257 0.0207083 0.0926125 0.119931 0.426617 0.118773 0.0957465 0.0648401 0.0942297 0.136774 0.058612 0.138074 0.0650489 0.0818006 0.0957236 0.099707 0.103623 0.111433 0.041711 0.084844 0.13915 0.132657 0.071688 0.104466 0.0292373 0.0777737 0.140157 0.105692 0.111681 0.0635084 0.137289 0.0844216 0.0549479 0.138056 0.0993534 0.0904626 0.13188 0.204857 0.0773117 0.0337772 0.112321 0.0773563 0.0956345 0.138684 0.0862938 0.0633155 0.0471359 0.0820197 0.138269 0.01027 0.132781 0.0893191 0.0693354 0.0852862 0.135818 0.181553 0.079584 0.136717 0.0485252 0.0935136 0.137963 0.0763962 0.087874 0.128023 0.0791783 0.0854952 0.139845 0.0041284 0.0633911 0.140057 0.284407 0.140151 0.0315323 0.13838 0.133017 0.139022 0.0491747 0.0446546 0.0553401 0.0394142 0.0847876 0.0579019 0.0619473 0.13272 0.0470692 0.0823399 0.127757 0.0926571 0.0722959 0.102821 0.043765 0.116065 0.0896064 0.120056 0.137908 0.139785 0.121847 0.0707756 0.0674367 0.0312376 0.129792 0.108142 0.116221 0.0598712 0.0860409 0.0828615 0.139188 0.140453 0.13018 0.0889401 0.10381 0.0723297 0.112339 0.0814648 0.103021 0.122066 0.161851 0.0642148 0.0924071 0.0292753 0.115315 0.0842697 0.0300848 0.135982 0.257636 0.0815814 0.111641 0.0933498 0.123341 0.035756 0.0805784 0.0535816 0.0355686 0.115089 0.139482 0.0592484 0.128474 0.0887611 0.0476212 0.105171 0.13414 0.093946 0.140113 0.128071 0.0781814 0.102088 0.107003 0.0959227 0.103577 0.136187 0.0712944 0.139662 0.0934159 0.133741 0.0357299 0.120995 0.0533226 0.0277783 0.0929388 0.050502 0.135385 0.134042 0.123392 0.0620029 0.0588412 0.0321836 0.069325 0.0823951 0.0579017 0.124811 0.139928 0.0412366 0.138876 0.131991 0.0830702 0.12373 0.131615 0.116485 0.0914723 0.0575354 0.134471 0.0300125 0.110125 0.0908787 0.0414314 0.0346585 0.0400046 0.0885993 0.107013 0.0545543 0.131707 0.0707734 0.108259 0.0963599 0.0861147 0.111439 0.116796 0.103163 0.0511576 0.107079 0.111377 0.120006 0.132344 0.0489475 0.0779962 0.129207 0.138124 0.0882205 0.130425 0.0706428 0.0418924 0.0808506 0.0750779 0.1358 0.140139 0.0788567 0.0668503 0.133006 0.140072 0.322644 0.0261266 0.122694 0.140028 0.0731288 0.140018 0.117575 0.0895831 0.0859065 0.0275471 0.140159 0.121412 0.113065 0.138647 0.13527 0.120186 0.0918218 0.0602899 0.0985327 0.100477 0.112377 0.322411 0.139029 0.137868 0.0985795 0.0949143 0.127715 0.0105154 0.074258 0.138041 0.0482807 0.0392031 0.074378 0.0514201 0.119246 0.0860833 0.0730624 0.13321 0.137003 0.133176 0.0955911 0.121187 0.0942582 0.122613 0.103663 0.0482411 0.0659746 0.0802936 0.0301349 0.0596131 0.0774719 0.0804344 0.105987 0.0562115 0.078149 0.0324656 0.0540826 0.233356 0.0593879 0.0639584 0.132894 0.145265 0.0697639 0.094886 0.116274 0.140049 0.0739353 0.121053 0.13501 0.132672 0.117419 0.140905 0.0997946 0.0666234 0.078419 0.085852 0.108227 0.086365 0.140044 0.0557728 0.0834946 0.139931 0.0917381 0.0949089 0.114421 0.0283863 0.0758851 0.0806312 0.0627421 0.0292855 0.109186 0.0980336 0.125803 0.0675443 0.0828404 0.120193 0.129673 0.107121 0.13378 0.116046 0.0372225 0.0755441 0.124694 0.0926179 0.11084 0.113893 0.138134 0.0838923 0.0755316 0.0409943 0.140107 0.078911 0.00720817 0.0979734 0.22961 0.0738678 0.0879227 0.0980328 0.0724029 0.0529461 0.116282 0.0544355 0.0258215 0.0562331 0.125876 0.130765 0.0790324 0.12502 0.0932495 0.100875 0.103559 0.132084 0.0743509 0.0606198 0.0976009 0.119174 0.140176 0.115543 0.0236634 0.134468 0.0365157 0.0522152 0.0995687 0.0900635 0.0442273 0.100387 0.0399202 0.098527 0.0737319 0.0375741 0.0422119 0.126717 0.0473881 0.0814345 0.132411 0.0387092 0.0819321 0.129146 0.0533781 0.10176 0.0372163 0.248991 0.0885787 0.0937176 0.0365752 0.138437 0.0664424 0.136985 0.0538745 0.096979 0.0346417 0.0654856 0.124906 0.0774122 0.12418 0.140139 0.0996683 0.0943388 0.0537066 0.0948465 0.137801 0.0812426 0.0970253 0.0739759 0.0257511 0.0725251 0.0918211 0.0294809 0.13198 0.0380963 0.0853205 0.121557 0.108466 0.0259986 0.0954432 0.11106 0.0637311 0.102347 0.0165869 0.137935 0.0417032 0.134673 0.10465 0.0740718 0.111022 0.0284299 0.120382 0.0649163 0.103051 0.0791772 0.0670931 0.0691929 0.132415 0.045423 0.0607104 0.0898488 0.0533967 0.0409659 0.107414 0.124822 0.136929 0.0852745 0.0725917 0.134133 0.0763808 0.0736374 0.103989 0.0656883 0.0965606 0.0340851 0.034177 0.232071 0.0662744 0.0737852 0.0419926 0.137427 0.0614278 0.0618624 0.103679 0.0973565 0.139467 0.129202 0.0913359 0.0841703 0.13406 0.0801425 0.0936792 0.0617084 0.100824 0.137831 0.126461 0.0669833 0.020186 0.0945172 0.079988 0.120835 0.0930529 0.13486 0.0578827 0.0827302 0.122957 0.0873709 0.0442141 0.0440247 0.0682648 0.0970103 0.108628 0.0555206 0.0959944 0.139119 0.0788269 0.13245 0.124235 0.0839993 0.102745 0.139108 0.0819669 0.135829 0.107231 0.0872036 0.0296837 0.0695138 0.0288089 0.136468 0.0212165 0.113655 0.0777467 0.0894196 0.137137 0.0752049 0.0845495 0.0862437 0.0917456 0.076604 0.12016 0.0387834 0.0756917 0.105195 0.0572024 0.100445 0.0724717 0.0864906 0.124483 0.132597 0.0922675 0.105034 0.13561 0.134383 0.140056 0.0119169 0.0292304 0.0908723 0.138298 0.0528991 0.0500274 0.0625901 0.137323 0.0726424 0.056369 0.132913 0.0454181 0.138134 0.123904 0.13935 0.138673 0.117774 0.107183 0.221688 0.130101 0.11381 0.132539 0.041905 0.0503748 0.0706057 0.140058 0.0252678 0.138387 0.0371005 0.315531 0.0291241 0.0769458 0.126025 0.0445934 0.0673177 0.0947625 0.310771 0.124063 0.351505 0.115442 0.107596 0.133838 0.0550695 0.135962 0.118853 0.135835 0.0919212 0.223146 0.129013 0.0258234 0.0781302 0.140013 0.078905 0.0914152 0.131247 0.0804403 0.0909481 0.131592 0.0966087 0.061712 0.0240841 0.0857034 0.0901279 0.139684 0.204272 0.120114 0.0891847 0.109918 0.137597 0.0713157 0.13983 0.362764 0.0792742 0.0331766 0.0567927 0.032908 0.0735516 0.0591775 0.0378169 0.139856 0.122115 0.141726 0.179435 0.0861504 0.110762 0.071487 0.138108 0.139738 0.0412885 0.139853 0.138896 0.0690956 0.117458 0.14021 0.103833 0.0665565 0.0482264 0.0609312 0.115237 0.130754 0.0875943 0.0439003 0.0389306 0.158419 0.0456142 0.138427 0.139049 0.13793 0.140111 0.0953201 0.0666794 0.13442 0.118475 0.082153 0.0705031 0.119969 0.0810064 0.0872374 0.0995507 0.219725 0.0767736 0.107612 0.0828193 0.0818224 0.0815163 0.0734711 0.120614 0.138893 0.0938197 0.132317 0.138406 0.139564 0.114382 0.0591165 0.139886 0.0552543 0.0689945 0.0974832 0.207878 0.133901 0.0751258 0.124466 0.135215 0.112999 0.0965194 0.0845334 0.129206 0.021004 0.0989823 0.0748211 0.0867093 0.140095 0.0791184 0.134771 0.113172 0.0817063 0.121574 0.107236 0.107183 0.0628723 0.0850191 0.0688641 0.0670044 0.0453793 0.093733 0.0634291 0.12733 0.139284 0.076255 0.138113 0.0273962 0.0158962 0.102282 0.0878968 0.0822107 0.0314589 0.0844224 0.105488 0.0874221 0.12375 0.128112 0.0780424 0.139185 0.108182 0.0774086 0.126342 0.0466556 0.0272449 0.129602 0.0111234 0.0948089 0.133995 0.0582198 0.134882 0.0763396 0.125764 0.0851748 0.0988384 0.0964869 0.0804993 0.129479 0.138467 0.097056 0.0559435 0.125298 0.132248 0.140039 0.0788916 0.117917 0.0960989 0.0991714 0.127209 0.0963623 0.132427 0.0920695 0.10565 0.0512631 0.13017 0.0593346 0.137906 0.139395 0.0766719 0.0397455 0.0786659 0.138894 0.129324 0.0367997 0.0525112 0.0800089 0.0602828 0.0995813 0.0719659 0.0470338 0.137602 0.0788018 0.137708 0.139665 0.1218 0.0471879 0.0397557 0.127141 0.0971997 0.0946686 0.0299854 0.115536 0.0445214 0.13721 0.0811691 0.0826465 0.0730235 0.133587 0.0462923 0.088229 0.0188301 0.130142 0.0931469 0.0509742 0.122839 0.0776379 0.0450338 0.0345831 0.0297499 0.118686 0.0833782 0.0705713 0.0349523 0.117796 0.10004 0.0380907 0.0327279 0.136204 0.138225 0.139228 0.0408022 0.00579719 0.0784955 0.0256427 0.0180812 0.118366 0.122454 0.0167175 0.0750724 0.138973 0.123614 0.0659143 0.0798779 0.140286 0.137063 0.10642 0.0672696 0.0773425 0.140105 0.122831 0.0903243 0.13989 0.0738759 0.122738 0.140063 0.114407 0.130319 0.0961071 0.134068 0.131027 0.0286427 0.0905416 0.0485639 0.0987827 0.0272909 0.0319483 0.081571 0.123498 0.107506 0.0834015 0.0872093 0.030795 0.0594482 0.0913686 0.127443 0.0545165 0.0423578 0.125627 0.138577 0.0598875 0.0270712 0.0467561 0.0565562 0.0865089 0.0724794 0.121222 0.0536484 0.145425 0.0817596 0.0755715 0.0431601 0.125076 0.13059 0.0625722 0.0458071 0.122596 0.118577 0.0608916 0.0850428 0.0357041 0.06924 0.130339 0.118065 0.123322 0.0404191 0.059274 0.0901052 0.0967011 0.0341405 0.029613 0.126809 0.137883 0.0971973 0.118422 0.105827 0.0701501 0.0520994 0.13123 0.0305384 0.132765 0.0299195 0.0260632 0.0753359 0.0824418 0.131125 0.077867 0.0832341 0.0476914 0.0389504 0.0872421 0.0872262 0.0747351 0.137792 0.0856978 0.0522297 0.0876391 0.0497011 0.134685 0.13754 0.13612 0.0855096 0.0134225 0.0840438 0.135851 0.137332 0.0506447 0.0529298 0.113529 0.115127 0.101486 0.0499005 0.0839746 0.100923 0.0449854 0.140175 0.0570192 0.137732 0.0601534 0.107331 0.0788505 0.0753449 0.0693717 0.050776 0.0452575 0.12328 0.0846117 0.106819 0.0287469 0.117515 0.084357 0.028418 0.107271 0.10941 0.0675087 0.14008 0.043675 0.0714631 0.0836466 0.140084 0.0900059 0.0676886 0.0418461 0.116718 0.0725648 0.0869046 0.0274189 0.0467615 0.0692924 0.0676086 0.118275 0.0273392 0.138631 0.13967 0.126601 0.0541228 0.0848014 0.100933 0.140173 0.0490645 0.0879296 0.0782322 0.13872 0.020413 0.0821569 0.109951 0.138093 0.113012 0.0843505 0.138823 0.0714332 0.0308422 0.108809 0.0592759 0.139738 0.139204 0.138615 0.10258 0.0512101 0.109107 0.0925186 0.0771546 0.0904989 0.0688628 0.0311868 0.102734 0.118291 0.0792977 0.381638 0.0417233 0.0338542 0.0114872 0.0683923 0.131034 0.0330021 0.0738329 0.108884 0.130429 0.0330946 0.0742722 0.031214 0.0505244 0.0992826 0.13167 0.0644063 0.103844 0.0837016 0.0784409 0.139696 0.139435 0.13898 0.0721036 0.0906582 0.106228 0.12252 0.147649 0.114166 0.132547 0.0936116 0.097101 0.0122037 0.066252 0.0584083 0.139644 0.0932147 0.0795836 0.0662731 0.0503695 0.0493986 0.140167 0.0656078 0.0962622 0.387427 0.0667448 0.0812939 0.154489 0.133938 0.0778698 0.100901 0.139636 0.116221 0.138105 0.108517 0.0704521 0.0951381 0.138552 0.115322 0.139358 0.0849565 0.0848707 0.0785167 0.134522 0.0815373 0.0745257 0.0667947 0.0408253 0.0086624 0.135626 0.0647527 0.128927 0.0364288 0.139149 0.114144 0.0655969 0.0324518 0.140598 0.0728595 0.0390825 0.0429474 0.0143715 0.137628 0.0917808 0.0671836 0.0849659 0.131365 0.0464827 0.220032 0.113837 0.131229 0.0469539 0.177829 0.0433328 0.139977 0.138536 0.0522728 0.0746806 0.0496576 0.119928 0.139037 0.0884258 0.0313741 0.0461686 0.0776474 0.132966 0.0770939 0.139507 0.124819 0.133792 0.0854632 0.138613 0.0326018 0.068842 0.0861283 0.0815387 0.122171 0.088255 0.139942 0.121865 0.0830689 0.0771248 0.0345103 0.0879211 0.073855 0.0595666 0.132373 0.0671582 0.0889048 0.0345862 0.0426239 0.139158 0.00639948 0.031611 0.112671 0.116996 0.0411696 0.159509 0.139991 0.136303 0.111673 0.0724868 0.080132 0.140122 0.0925332 0.140173 0.0993626 0.114638 0.0808922 0.0912754 0.0218274 0.0754481 0.100748 0.139813 0.0527928 0.100145 0.0809545 0.130444 0.062346 0.13741 0.137199 0.00752591 0.0756064 0.0906191 0.0275126 0.0333316 0.125538 0.134588 0.107918 0.0906355 0.116904 0.0619721 0.128981 0.0573222 0.121245 0.0946597 0.0123424 0.12551 0.140094 0.127569 0.0147479 0.0631012 0.0514836 0.0819482 0.0284391 0.0182929 0.133913 0.124965 0.128297 0.0585563 0.106275 0.0346941 0.0813295 0.139627 0.105801 0.0489311 0.124757 0.128058 0.123413 0.0707149 0.131835 0.0836119 0.12495 0.0655745 0.137067 0.0704302 0.0564251 0.118993 0.0259048 0.0862773 0.0383486 0.0629897 0.139625 0.0716858 0.0801791 0.104802 0.0352386 0.128583 0.110149 0.133076 0.126034 0.0177671 0.131822 0.139722 0.111927 0.0951343 0.0171058 0.0767985 0.0785675 0.0894121 0.11908 0.0719144 0.082961 0.134188 0.13977 0.045218 0.076457 0.0978562 0.116712 0.0852066 0.0637562 0.0958361 0.0830252 0.0840901 0.117851 0.0768 0.0533058 0.121856 0.103977 0.0611717 0.12194 0.0620745 0.070735 0.0255967 0.0511913 0.0852767 0.0527373 0.0531961 0.126888 0.0478911 0.122446 0.137735 0.127438 0.112269 0.139208 0.0697138 0.0193372 0.0911939 0.121196 0.0443503 0.0928356 0.13859 0.0859594 0.136829 0.0402814 0.0321709 0.134358 0.0485831 0.0407506 0.076081 0.0655035 0.11435 0.0967439 0.0770817 0.135157 0.0738145 0.0792041 0.122102 0.0758968 0.140159 0.117923 0.0890032 0.0508395 0.0562675 0.136359 0.0431323 0.0520434 0.0652028 0.0621893 0.0922982 0.12456 0.128275 0.130139 0.106104 0.0890022 0.0453865 0.0481962 0.0293538 0.0332817 0.0358611 0.128253 0.368896 0.0718721 0.0787583 0.114667 0.124774 0.122528 0.0666031 0.0982428 0.0945294 0.00549787 0.0755007 0.0453096 0.138707 0.0586208 0.0388767 0.0934252 0.139097 0.077931 0.100685 0.0508301 0.10481 0.0341025 0.0445084 0.100434 0.121166 0.00393612 0.0689528 0.0770195 0.0851025 0.0314638 0.082617 0.103125 0.139105 0.0875877 0.137548 0.0852791 0.139931 0.111609 0.102002 0.0800141 0.0418353 0.0812045 0.0412026 0.0712342 0.0910235 0.0361786 0.131113 0.11277 0.104043 0.0717601 0.108615 0.13692 0.135481 0.141659 0.129046 0.104381 0.13128 0.102204 0.136424 0.0837685 0.00626509 0.0426721 0.139727 0.130924 0.139932 0.132255 0.0994272 0.0997898 0.0687874 0.0407728 0.0573837 0.0384759 0.139539 0.0796436 0.0874792 0.152145 0.0734259 0.138159 0.0710444 0.0770376 0.138171 0.139655 0.0806284 0.0847971 0.0325231 0.137408 0.139168 0.0686972 0.0689735 0.140112 0.130239 0.128059 0.112259 0.0492861 0.135701 0.0849803 0.0772938 0.140204 0.140097 0.0120946 0.0753562 0.112499 0.105257 0.129558 0.125182 0.124003 0.129159 0.135515 0.0978144 0.0499119 0.0822628 0.134737 0.120732 0.0372651 0.0341066 0.0392346 0.0668694 0.139419 0.046234 0.0892651 0.0705658 0.131759 0.119649 0.114535 0.0435004 0.13623 0.137746 0.135345 0.0215132 0.107712 0.0821409 0.122909 0.111163 0.107436 0.0429613 0.0852772 0.116312 0.0896272 0.04735 0.0984891 0.128696 0.132186 0.0409715 0.0786569 0.0985552 0.0468919 0.057403 0.0567656 0.0802836 0.0963349 0.129351 0.0831534 0.106552 0.13328 0.0873836 0.154054 0.0853807 0.0125597 0.135946 0.0767058 0.0555924 0.104764 0.131812 0.0773088 0.121521 0.0738694 0.14019 0.0959567 0.108969 0.0417587 0.0499995 0.138212 0.086428 0.137817 0.125348 0.0848494 0.0802135 0.101985 0.132073 0.345761 0.0915625 0.0902503 0.100761 0.0299547 0.139483 0.086892 0.0113185 0.0807627 0.102829 0.129174 0.0680949 0.119944 0.139245 0.0580567 0.187451 0.121199 0.135434 0.137314 0.0871738 0.135133 0.114047 0.0376434 0.0428135 0.107393 0.00533174 0.126609 0.0769107 0.066061 0.127777 0.122695 0.137404 0.13788 0.0980274 0.113279 0.0285611 0.101048 0.114569 0.127603 0.0897835 0.130409 0.0726233 0.113507 0.0542041 0.125934 0.119328 0.0733536 0.0344273 0.0793066 0.00596905 0.126802 0.0789584 0.0940225 0.0493393 0.139126 0.0545334 0.0176922 0.0627493 0.0974481 0.131732 0.131898 0.107416 0.0464131 0.121985 0.0879404 0.134954 0.0120789 0.065304 0.0428997 0.0556332 0.0512533 0.0926257 0.0317503 0.0253795 0.0615992 0.0612989 0.0843382 0.0851946 0.040074 0.122173 0.12652 0.135811 0.128261 0.0357712 0.111426 0.111738 0.0757709 0.0929322 0.139082 0.0555426 0.137648 0.0488791 0.117079 0.11807 0.0518132 0.0679951 0.139657 0.083736 0.0521297 0.140036 0.097735 0.128802 0.0547477 0.138239 0.0874587 0.121341 0.0804774 0.138621 0.139569 0.00723908 0.0808913 0.0556593 0.117437 0.140196 0.114966 0.0665156 0.122943 0.074629 0.0721425 0.0549641 0.0912881 0.0917425 0.0752268 0.0661303 0.0974272 0.0974688 0.0847538 0.102069 0.121807 0.0783859 0.0812408 0.119809 0.100553 0.033883 0.143748 0.130486 0.0326784 0.085197 0.0725727 0.0619224 0.139617 0.0455796 0.0303524 0.0996745 0.0550746 0.103998 0.03516 0.104216 0.140182 0.13497 0.0993203 0.0880776 0.130255 0.0543145 0.0826756 0.139477 0.08875 0.065143 0.0931003 0.0431214 0.074982 0.130443 0.135523 0.124044 0.0769946 0.0721352 0.0804559 0.0748315 0.0402812 0.138338 0.135716 0.0489522 0.0904237 0.0964641 0.128327 0.0642771 0.0671474 0.0677936 0.11891 0.134975 0.0161957 0.138936 0.053105 0.134801 0.104765 0.0913797 0.0842164 0.0720988 0.00833159 0.0173621 0.084015 0.0571443 0.019678 0.122028 0.134529 0.0365014 0.23759 0.138088 0.140194 0.136879 0.0740986 0.0469489 0.078453 0.104786 0.120749 0.06748 0.0657412 0.0965731 0.0629955 0.0576632 0.128886 0.080592 0.0726288 0.140191 0.130799 0.106126 0.07857 0.140161 0.0777534 0.0660544 0.115543 0.13549 0.0136543 0.167485 0.120159 0.065746 0.0838506 0.078794 0.0976478 0.138387 0.127378 0.0674234 0.105752 0.13669 0.0703593 0.0397072 0.139418 0.0808692 0.0314146 0.18384 0.00469285 0.00720228 0.138168 0.111745 0.119923 0.0405092 0.0846524 0.0434647 0.116163 0.1275 0.135482 0.108979 0.138973 0.129594 0.108288 0.128899 0.0534063 0.112719 0.0801909 0.066829 0.0766005 0.0878077 0.0304305 0.0385077 0.0509036 0.101695 0.0418509 0.132761 0.120857 0.0507093 0.0725294 0.0447099 0.12566 0.120351 0.10952 0.0350949 0.0741524 0.123322 0.072309 0.12052 0.0635787 0.0712491 0.12918 0.137799 0.134264 0.064332 0.0887133 0.0957694 0.115537 0.140214 0.0787396 0.0875194 0.12786 0.129026 0.11367 0.135281 0.0578545 0.037739 0.120679 0.121129 0.134199 0.0267074 0.0281645 0.0413833 0.0779717 0.134853 0.13395 0.0783152 0.128634 0.0760326 0.0865118 0.0991451 0.108623 0.132515 0.0395374 0.136202 0.0999093 0.0786733 0.113305 0.131629 0.0207756 0.0465775 0.100619 0.0984886 0.126347 0.138422 0.0279004 0.0584536 0.0548906 0.137735 0.0289082 0.138279 0.0660806 0.0851052 0.0820409 0.101146 0.127702 0.139405 0.0718302 0.139895 0.0338997 0.116246 0.0335656 0.136127 0.0888046 0.101609 0.0966344 0.140203 0.0282029 0.102089 0.0983209 0.0865324 0.0867293 0.139946 0.140171 0.0733724 0.0398826 0.11762 0.0594415 0.0914096 0.0384267 0.128611 0.0865126 0.119185 0.139201 0.093409 0.129008 0.108237 0.0928738 0.082646 0.116947 0.143062 0.111829 0.137629 0.0866445 0.0924637 0.132922 0.0774868 0.0733617 0.137164 0.0755437 0.186586 0.108197 0.138542 0.0641815 0.0975594 0.120152 0.0357747 0.115705 0.0872998 0.102503 0.0978413 0.0492128 0.103747 0.110492 0.0917804 0.0828557 0.0812023 0.0747066 0.137756 0.031258 0.139749 0.0286583 0.123675 0.066378 0.130655 0.0742474 0.115319 0.120985 0.081044 0.0363169 0.0367969 0.0832029 0.127737 0.0953713 0.0879718 0.108304 0.127978 0.108044 0.0803424 0.0398351 0.0471492 0.0801918 0.0882982 0.0953442 0.0488507 0.0819611 0.0865783 0.342054 0.0420636 0.133662 0.0214328 0.0252179 0.0927997 0.0109917 0.119391 0.0795251 0.140075 0.12926 0.0214577 0.0968896 0.0983874 0.0954636 0.0717067 0.0254658 0.114261 0.0806536 0.0529331 0.0353041 0.139201 0.0533211 0.0288236 0.129114 0.0521236 0.0449011 0.136064 0.089628 0.0715057 0.2283 0.0339491 0.0772554 0.127514 0.130627 0.0314453 0.11513 0.0517311 0.139536 0.121609 0.0321747 0.0874501 0.0727027 0.0770669 0.131812 0.0447928 0.0283403 0.0853873 0.109948 0.0255592 0.0187416 0.0741435 0.0345518 0.102196 0.130853 0.140123 0.069272 0.0821297 0.0838419 0.0544223 0.116738 0.113758 0.137202 0.132478 0.054838 0.137252 0.0529283 0.0682491 0.0352403 0.0846058 0.0564301 0.134452 0.0836308 0.123588 0.117679 0.118915 0.0901018 0.102821 0.0813326 0.0951463 0.0869193 0.0258097 0.176343 0.0929626 0.0944093 0.140036 0.0502345 0.0264424 0.1308 0.140025 0.1402 0.132784 0.0825447 0.136818 0.0253975 0.0465427 0.140171 0.0863863 0.0702524 0.0335154 0.108765 0.117302 0.0997194 0.123707 0.0784884 0.130299 0.00821372 0.134483 0.123598 0.0914589 0.0480897 0.118304 0.100774 0.0900171 0.111337 0.0790622 0.041562 0.0389971 0.0527603 0.0952955 0.0415317 0.112773 0.126244 0.101738 0.139349 0.138386 0.0778938 0.12305 0.0529312 0.084443 0.082207 0.0350579 0.118119 0.129451 0.110379 0.059887 0.100309 0.0451176 0.0749747 0.119102 0.0893147 0.128641 0.0966536 0.0809155 0.0286203 0.0709921 0.0698073 0.109884 0.12452 0.134759 0.0700312 0.086795 0.0257674 0.139582 0.139839 0.0933624 0.00495418 0.125115 0.0268784 0.134955 0.0540007 0.0732419 0.139972 0.0895506 0.14019 0.0980881 0.0692499 0.115913 0.169317 0.092732 0.116077 0.0808532 0.0500162 0.0910273 0.131671 0.0834675 0.0777268 0.0773389 0.119918 0.157588 0.126798 0.0299107 0.0853839 0.0836851 0.130073 0.0769148 0.0826264 0.0787531 0.125599 0.139062 0.116507 0.0799648 0.0832781 0.13562 0.140309 0.126377 0.0492285 0.127283 0.0852848 0.088147 0.0945319 0.0413804 0.0587265 0.0790021 0.050618 0.07825 0.0608517 0.111949 0.0865986 0.102272 0.125934 0.0920184 0.12415 0.131615 0.138871 0.0538279 0.132836 0.265229 0.13279 0.036072 0.125824 0.123701 0.0741492 0.067234 0.109591 0.0530313 0.127878 0.14017 0.0989761 0.0875042 0.135082 0.0946391 0.00689235 0.107143 0.13829 0.108985 0.0322491 0.108114 0.033594 0.104172 0.0679436 0.125838 0.0829156 0.0794911 0.0404764 0.0763299 0.13948 0.140072 0.0706292 0.126574 0.0847361 0.0694631 0.042408 0.033945 0.0498138 0.0712238 0.0594152 0.130737 0.117351 0.122599 0.0402889 0.0880617 0.0564803 0.0312107 0.134971 0.0997589 0.139822 0.0273128 0.0724126 0.138312 0.142903 0.0541523 0.0563294 0.113426 0.110835 0.0993525 0.0801545 0.08852 0.140057 0.105463 0.117744 0.012382 0.106285 0.124958 0.0398583 0.0476165 0.0471929 0.047999 0.0620218 0.141611 0.0288173 0.0524027 0.0233847 0.0292896 0.0788312 0.131343 0.0772146 0.0803361 0.087829 0.140187 0.138295 0.074665 0.0459946 0.0470067 0.0258216 0.139161 0.0283945 0.035528 0.083573 0.118491 0.0877145 0.137291 0.0743662 0.104244 0.0335135 0.0748274 0.139407 0.0900058 0.109124 0.105941 0.129169 0.135744 0.0313577 0.121033 0.104611 0.0566492 0.0352339 0.100755 0.0882165 0.132027 0.127762 0.14004 0.0281686 0.117677 0.0455155 0.139608 0.133975 0.112565 0.0436786 0.138231 0.0971726 0.0295994 0.121822 0.0856459 0.0253517 0.0568585 0.0678617 0.0898821 0.139489 0.0548236 0.105032 0.0489372 0.0667987 0.0738588 0.109159 0.140178 0.084174 0.0802923 0.046581 0.122272 0.0864544 0.119074 0.0630012 0.139049 0.0251157 0.131765 0.103675 0.0404396 0.046854 0.135641 0.00862961 0.113745 0.0747931 0.155457 0.0887673 0.0695624 0.0842148 0.0894283 0.123437 0.0875622 0.0975253 0.128711 0.149437 0.134838 0.0694936 0.117153 0.0285353 0.05668 0.100968 0.138388 0.0760621 0.140168 0.0803318 0.0297028 0.133443 0.104671 0.133697 0.121341 0.150827 0.10549 0.046634 0.12828 0.0517407 0.0923789 0.0585601 0.061225 0.0625491 0.121436 0.0967739 0.265115 0.0707255 0.123078 0.119226 0.0749723 0.0291172 0.0876918 0.0273069 0.0615367 0.138718 0.0376048 0.124098 0.120198 0.134814 0.123938 0.293626 0.0812126 0.100218 0.135965 0.120367 0.0401162 0.0447442 0.077733 0.0748576 0.123858 0.0481656 0.0790491 0.131412 0.00791945 0.0946052 0.140184 0.095633 0.131079 0.0337698 0.0980742 0.0944408 0.0979202 0.0867555 0.0467904 0.081445 0.105209 0.13083 0.0930488 0.0930794 0.140181 0.0795107 0.127428 0.083523 0.0667898 0.0910095 0.22015 0.121619 0.0919595 0.118007 0.130743 0.106412 0.0823986 0.0662851 0.132756 0.0719767 0.0877901 0.138021 0.137226 0.0507596 0.0297096 0.0876599 0.11302 0.0892088 0.119446 0.069123 0.099246 0.0788803 0.0942443 0.114894 0.0703507 0.117762 0.0702061 0.139382 0.140049 0.111803 0.114666 0.108071 0.116996 0.139561 0.0438269 0.136881 0.0749211 0.0404453 0.1247 0.0682988 0.0912946 0.034985 0.0659522 0.104515 0.140057 0.0803252 0.0565153 0.0820363 0.100855 0.0648365 0.136979 0.0909378 0.0740455 0.122083 0.134767 0.11459 0.0787791 0.136989 0.0981741 0.0276977 0.0562942 0.139672 0.0994745 0.137032 0.0900039 0.136858 0.110654 0.0487581 0.132348 0.114122 0.139263 0.0356011 0.0941377 0.0670041 0.0779488 0.0995953 0.131749 0.11237 0.137708 0.068071 0.0800576 0.138199 0.0876025 0.0754166 0.0918558 0.0486053 0.126606 0.10133 0.0672139 0.0645738 0.0550051 0.0504677 0.0457889 0.119472 0.00863095 0.131617 0.139142 0.12609 0.0134998 0.088837 0.127452 0.124841 0.137925 0.0974705 0.053952 0.114205 0.0808159 0.0301779 0.0978592 0.117534 0.0655044 0.121391 0.127905 0.0620239 0.102488 0.290516 0.0782652 0.0701759 0.0529001 0.0854398 0.0762089 0.0706227 0.14018 0.200427 0.0654913 0.203334 0.0045033 0.0374041 0.112151 0.0937187 0.0985549 0.14006 0.0939889 0.0665666 0.13259 0.0604792 0.0833331 0.0683931 0.0978277 0.109448 0.146233 0.135252 0.0930033 0.0425751 0.0518953 0.0457387 0.0278524 0.045618 0.126734 0.0965958 0.139936 0.13967 0.13988 0.0585247 0.0185959 0.101359 0.0909329 0.137958 0.0898204 0.0943699 0.11641 0.0788906 0.0946948 0.129334 0.139899 0.0978191 0.139989 0.0965444 0.0300942 0.139553 0.00920702 0.138637 0.115297 0.122493 0.126011 0.0915863 0.0670009 0.132526 0.041353 0.052124 0.0775367 0.072101 0.123059 0.124061 0.0891544 0.120749 0.025193 0.0725594 0.0435998 0.136239 0.374224 0.0939735 0.139217 0.0895375 0.0697119 0.133837 0.133262 0.0350634 0.108742 0.114928 0.0720396 0.0573215 0.101289 0.0922935 0.137878 0.125752 0.120615 0.138082 0.128941 0.0533734 0.135429 0.105206 0.140106 0.0254406 0.134598 0.133643 0.0705065 0.13917 0.0943514 0.138217 0.129026 0.132821 0.0620814 0.0475143 0.0912266 0.0920119 0.137591 0.133532 0.0969479 0.100463 0.0945989 0.109482 0.104272 0.138893 0.116419 0.0229041 0.136514 0.105466 0.139583 0.0499449 0.0625378 0.0700891 0.0310676 0.0655255 0.0657121 0.0275046 0.0708925 0.292172 0.0473897 0.0289236 0.032178 0.109878 0.0710836 0.136635 0.0235833 0.057645 0.0700373 0.0664701 0.0941026 0.130013 0.128494 0.137775 0.117663 0.0483836 0.088054 0.324478 0.0402555 0.140197 0.0614727 0.139828 0.0929003 0.116678 0.0757643 0.092179 0.0752335 0.138062 0.0449065 0.122188 0.073223 0.110713 0.124371 0.138628 0.0689995 0.138126 0.126688 0.209487 0.0859223 0.0812822 0.106389 0.101952 0.0921564 0.0961716 0.0633394 0.136861 0.139995 0.0746204 0.138811 0.0874296 0.051883 0.0476476 0.0374738 0.138527 0.128914 0.076177 0.0156913 0.0445 0.0216125 0.0698595 0.0271841 0.0775511 0.0302927 0.357836 0.109122 0.10779 0.025856 0.115001 0.0889698 0.0336647 0.0990421 0.0847153 0.0291201 0.135846 0.309137 0.0708523 0.105651 0.140204 0.0778441 0.139682 0.0665346 0.0828196 0.113355 0.0964664 0.0851108 0.120947 0.0494022 0.114379 0.0475785 0.0758 0.075073 0.0690535 0.124615 0.0727609 0.133427 0.118662 0.0850059 0.132949 0.139211 0.0384986 0.153279 0.0376841 0.139576 0.292594 0.121356 0.0906851 0.139376 0.0996868 0.140084 0.139323 0.0866005 0.0508709 0.0645084 0.0395504 0.0435683 0.0411658 0.140123 0.00802877 0.108419 0.0556091 0.109973 0.0893121 0.109033 0.0847826 0.0871042 0.138913 0.137928 0.0788124 0.0310464 0.030789 0.0328401 0.0902561 0.137304 0.0897111 0.0518436 0.0528191 0.1361 0.0608899 0.0744355 0.0835369 0.00926538 0.108916 0.0803214 0.0671045 0.0948627 0.136932 0.0695498 0.131394 0.132482 0.140094 0.337213 0.125904 0.135159 0.0465796 0.0794649 0.0986008 0.0975418 0.0901753 0.0352082 0.0336588 0.139646 0.0530092 0.0798363 0.373249 0.134018 0.139153 0.0983032 0.116908 0.0478753 0.137385 0.0764782 0.0930061 0.0849313 0.0951296 0.0631102 0.136385 0.0394077 0.0837523 0.0753274 0.0833012 0.0260866 0.138058 0.01157 0.0599515 0.0808912 0.0965721 0.212529 0.126458 0.121849 0.133707 0.107021 0.138337 0.133574 0.125417 0.138284 0.115937 0.130387 0.132538 0.0787092 0.0785137 0.115319 0.058845 0.138267 0.0767726 0.0599463 0.0797396 0.100503 0.0662646 0.111381 0.113944 0.0755472 0.101973 0.10363 0.136022 0.119513 0.0614623 0.101717 0.0582329 0.13557 0.0744823 0.122389 0.113887 0.0220491 0.140169 0.0825166 0.0810725 0.061617 0.139248 0.0406306 0.124716 0.133025 0.101515 0.128983 0.125249 0.118383 0.0515003 0.0773274 0.105107 0.109698 0.02721 0.108448 0.135354 0.0763481 0.0768173 0.12802 0.0771344 0.12992 0.00825491 0.0704369 0.0960244 0.13002 0.115484 0.336439 0.0755304 0.041567 0.0106925 0.117326 0.0504402 0.0828341 0.0783868 0.0239967 0.145745 0.0565518 0.130074 0.140013 0.110883 0.0728054 0.0251935 0.125536 0.103339 0.0967718 0.0921036 0.0741873 0.0507406 0.10393 0.0902661 0.131286 0.0862448 0.136565 0.0280887 0.0838968 0.127106 0.126755 0.076638 0.0490376 0.0495064 0.0177969 0.137826 0.0768974 0.138757 0.137308 0.138863 0.080134 0.125515 0.0693195 0.0351881 0.0770806 0.116471 0.105536 0.137558 0.0870713 0.120024 0.129275 0.0426083 0.10313 0.055199 0.0334336 0.12592 0.076286 0.0865118 0.138569 0.0377679 0.0903445 0.0818073 0.0965642 0.0545626 0.10874 0.13936 0.0465673 0.100785 0.117587 0.138618 0.101718 0.0503288 0.0715239 0.0514302 0.13505 0.139015 0.127924 0.167135 0.101064 0.0779855 0.0760967 0.139757 0.138653 0.0729437 0.0326766 0.0841451 0.0252764 0.0347154 0.026192 0.140157 0.374981 0.0524228 0.11199 0.0894677 0.0772443 0.131055 0.138747 0.120737 0.0284114 0.0852479 0.136919 0.135438 0.0559883 0.227897 0.0400538 0.135721 0.0371322 0.0552775 0.130574 0.107568 0.0450283 0.120251 0.0627271 0.0679588 0.0611573 0.115599 0.131139 0.139791 0.0698823 0.0252976 0.0387065 0.0865973 0.0713374 0.0424166 0.0851882 0.13319 0.0967925 0.138915 0.185123 0.0951892 0.131775 0.112598 0.139459 0.138902 0.0654245 0.0754648 0.0502511 0.032412 0.138148 0.0469121 0.137679 0.0447661 0.0589296 0.0411621 0.0171192 0.0350205 0.0349807 0.138706 0.0462632 0.0393127 0.0271103 0.0896404 0.031973 0.039239 0.0697972 0.0673897 0.13927 0.0309375 0.0654492 0.135477 0.119126 0.133059 0.135908 0.0412465 0.116249 0.0918445 0.0997574 0.0339983 0.105324 0.0965319 0.0399298 0.0487372 0.0512288 0.0309513 0.0407471 0.0828896 0.101507 0.16172 0.0790399 0.0495719 0.139975 0.113436 0.112368 0.0723796 0.139107 0.0470281 0.125583 0.116492 0.0830289 0.17547 0.0495896 0.0608785 0.0490132 0.139238 0.0866846 0.0760299 0.083929 0.0167217 0.0395473 0.120626 0.121554 0.140098 0.126334 0.135429 0.136754 0.13198 0.0892001 0.0865427 0.0415865 0.127364 0.0479055 0.0902555 0.130686 0.0699254 0.134702 0.0626372 0.0925512 0.0999994 0.0822533 0.108924 0.00622262 0.071476 0.0265132 0.0498377 0.0769121 0.0715661 0.145336 0.132204 0.0561658 0.139172 0.0307079 0.119603 0.106047 0.128113 0.127419 0.0419085 0.0788317 0.300139 0.0902667 0.0677995 0.0631806 0.0965117 0.106574 0.0784716 0.0536969 0.129726 0.133894 0.120579 0.132655 0.0546121 0.0435991 0.140097 0.140175 0.0287643 0.139078 0.14002 0.0887494 0.0914634 0.0865036 0.0994396 0.0960928 0.0362865 0.0128485 0.0298897 0.0913927 0.116296 0.139852 0.0831225 0.0197626 0.117767 0.0569435 0.0484652 0.0929148 0.124894 0.0749818 0.0808602 0.0633445 0.315085 0.0789249 0.122452 0.109416 0.0309137 0.0767621 0.0687674 0.124019 0.136575 0.13308 0.0608176 0.0307302 0.0393055 0.0327431 0.125273 0.0729252 0.100109 0.0366456 0.0660323 0.125983 0.0785636 0.140039 0.138586 0.0843334 0.0734711 0.092079 0.341975 0.0996361 0.0935849 0.0275864 0.0846212 0.118713 0.129561 0.105132 0.113984 0.0729706 0.0403202 0.0685946 0.0907451 0.139123 0.0889513 0.139968 0.109807 0.0913584 0.0848314 0.134221 0.0394493 0.0892562 0.139915 0.232356 0.0854698 0.0709473 0.0858555 0.137976 0.0706466 0.0596795 0.0629677 0.132521 0.0332569 0.0599759 0.101243 0.101679 0.0210805 0.104747 0.044044 0.378383 0.13274 0.130663 0.405936 0.138546 0.0744548 0.139247 0.135188 0.0776018 0.0499395 0.0876366 0.0803189 0.122566 0.08328 0.0977204 0.0464146 0.102378 0.0390884 0.0607372 0.113669 0.0256573 0.138629 0.134216 0.122689 0.0547695 0.0743393 0.11856 0.108752 0.0925597 0.0793711 0.0509146 0.139944 0.114836 0.0418293 0.0981794 0.0841882 0.0486625 0.030913 0.0275923 0.044787 0.114745 0.139304 0.0467301 0.117362 0.0648276 0.0629883 0.0845189 0.0396513 0.0499534 0.0874367 0.127299 0.0816217 0.078879 0.137366 0.0847318 0.0481575 0.0808797 0.0716587 0.0885539 0.0736326 0.10106 0.0908024 0.139962 0.136133 0.13977 0.0427265 0.0712236 0.0789025 0.135296 0.0465821 0.107736 0.0508709 0.137627 0.140091 0.06801 0.0669431 0.123412 0.0670752 0.0398915 0.0816299 0.0712657 0.0752695 0.0999993 0.112187 0.0520853 0.0514512 0.135946 0.00448842 0.031618 0.0432854 0.102906 0.0449354 0.13608 0.128478 0.0744173 0.132918 0.109169 0.0521277 0.133607 0.0504202 0.0926997 0.00529729 0.0880556 0.0566621 0.0616589 0.0774454 0.0704971 0.122613 0.0252206 0.130591 0.097723 0.0419173 0.0908442 0.0694229 0.0654127 0.16688 0.0634174 0.0831203 0.114967 0.104191 0.13901 0.0901717 0.128592 0.137328 0.139428 0.13754 0.0233028 0.042871 0.0543769 0.0863328 0.130565 0.0410012 0.0369334 0.0374647 0.104709 0.0381075 0.0314599 0.0581031 0.0342086 0.118116 0.111025 0.137911 0.0545984 0.133106 0.136144 0.347907 0.0777832 0.124122 0.0823198 0.113049 0.112286 0.125963 0.0548099 0.0659674 0.0326824 0.0253128 0.0233921 0.101231 0.139159 0.0261085 0.129975 0.0261528 0.0901623 0.0735502 0.134071 0.0970056 0.127785 0.0882061 0.042026 0.102616 0.0603258 0.110541 0.215718 0.063363 0.139592 0.135088 0.125445 0.125533 0.080108 0.0556961 0.0745403 0.140017 0.108125 0.0994977 0.0966953 0.0450855 0.13735 0.0807503 0.13304 0.0760309 0.102147 0.134956 0.138759 0.0871278 0.0367307 0.137965 0.0583902 0.13952 0.128783 0.0684209 0.0781393 0.0670163 0.0943119 0.0941366 0.0932745 0.104419 0.140306 0.0851336 0.0829559 0.0444601 0.13152 0.0921543 0.114408 0.0544748 0.133419 0.0830132 0.0739337 0.0707046 0.121854 0.0465864 0.0800653 0.0682474 0.0553004 0.0286721 0.0831643 0.106382 0.129464 0.0874535 0.0604122 0.13531 0.0992141 0.0112192 0.102858 0.131191 0.108844 0.138489 0.067044 0.0340608 0.0752194 0.139535 0.135435 0.0985253 0.139464 0.0647328 0.0340843 0.132711 0.100405 0.116615 0.12793 0.0473623 0.034653 0.0663975 0.0995795 0.127863 0.083483 0.0816346 0.12947 0.13701 0.138789 0.102723 0.12123 0.0313894 0.153302 0.0706339 0.140057 0.0596976 0.140052 0.138029 0.137165 0.11584 0.132151 0.119183 0.0273354 0.071705 0.103058 0.0880425 0.128227 0.0134596 0.0323784 0.0865018 0.13917 0.0668901 0.119635 0.136139 0.13543 0.119443 0.0816396 0.119287 0.0344576 0.140062 0.133855 0.128078 0.104341 0.139196 0.0370639 0.110962 0.140046 0.124679 0.140147 0.129407 0.102931 0.0880247 0.139575 0.138507 0.0306343 0.108914 0.130387 0.098388 0.104825 0.050178 0.0747201 0.0394204 0.132256 0.13866 0.139168 0.0732504 0.0897488 0.0459692 0.125122 0.123861 0.0675001 0.0616723 0.0601341 0.127225 0.0279397 0.0897487 0.0702132 0.0312793 0.0491972 0.0387783 0.0505372 0.108077 0.0726031 0.139666 0.0427513 0.137515 0.0142105 0.131387 0.090918 0.0670449 0.0318019 0.091298 0.138394 0.0859159 0.0739292 0.229601 0.0508337 0.0250879 0.026116 0.140102 0.0617218 0.0755309 0.0935876 0.116872 0.071147 0.0445908 0.104558 0.101667 0.117079 0.138459 0.0457319 0.0939013 0.132362 0.0646498 0.129917 0.0905687 0.0556072 0.0961477 0.124524 0.138672 0.14012 0.0671314 0.110431 0.00943565 0.123333 0.114896 0.0841251 0.0729912 0.0839826 0.139971 0.139606 0.121127 0.102384 0.0783479 0.139985 0.032962 0.0823104 0.0693756 0.0541932 0.0512086 0.040362 0.0451366 0.143831 0.0998662 0.095791 0.0827983 0.0438335 0.0975898 0.116406 0.0774435 0.105558 0.128182 0.1046 0.070068 0.0786101 0.117928 0.133189 0.0779799 0.139688 0.105838 0.133902 0.219164 0.0617613 0.135414 0.119738 0.126388 0.134289 0.0626268 0.104861 0.0454057 0.125125 0.0935683 0.125475 0.0503847 0.12884 0.140173 0.103861 0.101554 0.0283459 0.0410667 0.0719979 0.117639 0.0984728 0.139539 0.129385 0.0992836 0.0767444 0.0327238 0.157011 0.100011 0.0835115 0.0290835 0.0680928 0.0519685 0.0544453 0.0398749 0.117526 0.126332 0.0922356 0.138959 0.138693 0.115318 0.107906 0.0764945 0.102195 0.11264 0.129391 0.11007 0.0709754 0.090362 0.0799069 0.12038 0.0965889 0.130327 0.0403191 0.134005 0.130459 0.123569 0.13745 0.10565 0.113711 0.0834492 0.0547902 0.0356835 0.0122513 0.079268 0.109866 0.133127 0.0553665 0.128961 0.0731363 0.13724 0.0961938 0.036386 0.0255779 0.0769913 0.0499968 0.0226417 0.112297 0.0469643 0.0831436 0.0263801 0.107564 0.108966 0.0223993 0.0528455 0.0421369 0.0923997 0.122525 0.0302751 0.0929086 0.0983328 0.100955 0.0797823 0.0691592 0.0837007 0.0652082 0.135809 0.121202 0.137801 0.100457 0.0506708 0.0866232 0.02863 0.0948639 0.095595 0.108126 0.109599 0.140018 0.13792 0.132303 0.115009 0.120173 0.075142 0.113993 0.0966287 0.13702 0.103126 0.0708583 0.139508 0.132718 0.105355 0.139005 0.0412645 0.052506 0.068811 0.121731 0.0915697 0.0937715 0.133504 0.0488146 0.0400767 0.132659 0.0844125 0.080288 0.071879 0.132194 0.106365 0.137228 0.191179 0.0767993 0.0332659 0.09383 0.0804264 0.088829 0.0328519 0.0510781 0.00925569 0.0336957 0.114861 0.0500818 0.127526 0.0771577 0.00938771 0.0596569 0.13579 0.074414 0.0401824 0.120209 0.125923 0.163252 0.264293 0.0943258 0.1262 0.0460749 0.133272 0.139014 0.052168 0.0444867 0.0817783 0.383011 0.137098 0.133743 0.132377 0.0607288 0.0764857 0.0454708 0.117728 0.128241 0.134914 0.104859 0.103879 0.13169 0.00965845 0.0664573 0.0746008 0.130577 0.0314998 0.0424613 0.117714 0.0733745 0.0737316 0.134751 0.112558 0.133071 0.0756297 0.118466 0.119186 0.0500304 0.0843553 0.0998369 0.137353 0.0330185 0.139294 0.113911 0.0575305 0.110123 0.0468608 0.140069 0.134228 0.138743 0.136793 0.0854258 0.0717859 0.114485 0.114383 0.100549 0.0560649 0.132754 0.13268 0.0102354 0.105396 0.132626 0.138814 0.0101371 0.0699811 0.0392787 0.0731403 0.105538 0.0329685 0.0623751 0.126299 0.13795 0.054239 0.124263 0.0917237 0.137283 0.128893 0.0776356 0.108956 0.129717 0.0962258 0.112255 0.0633993 0.120541 0.136225 0.0958023 0.0166892 0.0811725 0.0538461 0.0854156 0.0545313 0.0833893 0.0715915 0.0980048 0.0941031 0.139965 0.0619939 0.0504534 0.138394 0.137485 0.109893 0.0133691 0.0814812 0.117096 0.0987498 0.0172585 0.0522876 0.136521 0.0472028 0.106122 0.052637 0.12365 0.105349 0.0758667 0.138354 0.123877 0.137918 0.111174 0.0979807 0.136954 0.0679805 0.0532262 0.0765498 0.13173 0.131192 0.0917965 0.139305 0.0556523 0.0493986 0.115021 0.113492 0.101558 0.0598157 0.127989 0.00830026 0.0936038 0.128517 0.139267 0.0523522 0.138448 0.0935245 0.0624779 0.00934909 0.110948 0.0385942 0.131571 0.0858953 0.0391095 0.119377 0.112823 0.0391734 0.137299 0.129029 0.139275 0.111326 0.0571817 0.0424262 0.138745 0.0939713 0.032155 0.0642908 0.0512297 0.0726082 0.0984689 0.0208925 0.090318 0.0844537 0.0277438 0.115089 0.1421 0.0345087 0.131527 0.0539804 0.103299 0.126992 0.121707 0.0772863 0.0949164 0.113065 0.116214 0.0268476 0.108101 0.0754942 0.343621 0.0867712 0.0634475 0.0317945 0.111231 0.139221 0.0613723 0.136726 0.138836 0.0765032 0.111135 0.123434 0.129489 0.134076 0.125269 0.139166 0.0489624 0.135054 0.140065 0.12284 0.126467 0.137209 0.0238468 0.0241734 0.0431026 0.0532012 0.131739 0.10848 0.0797359 0.0942915 0.0902138 0.131257 0.0690084 0.0705815 0.0314075 0.13106 0.0424081 0.138844 0.0733903 0.134155 0.0455207 0.112087 0.0367024 0.0711322 0.0338056 0.140151 0.0602097 0.137243 0.128195 0.134207 0.0365095 0.13635 0.0850571 0.0722365 0.0139477 0.116797 0.120939 0.0659858 0.0584435 0.0687379 0.09774 0.119269 0.0506625 0.133843 0.114369 0.0373799 0.13284 0.111516 0.11516 0.0374024 0.137103 0.0906258 0.054281 0.131874 0.110321 0.055341 0.042247 0.0590624 0.126084 0.102318 0.0569774 0.114004 0.0788203 0.0843678 0.0639327 0.122905 0.0969473 0.0847615 0.0531264 0.139086 0.0889263 0.139661 0.0290222 0.0974678 0.0319591 0.13072 0.114835 0.0934899 0.136212 0.0898947 0.0337391 0.0469337 0.0217514 0.0153959 0.133895 0.112625 0.0525866 0.0353995 0.0477221 0.348016 0.0583449 0.130446 0.0902577 0.0499529 0.071073 0.0625379 0.125497 0.0554357 0.131799 0.0499476 0.0944609 0.0733311 0.104339 0.0550493 0.127796 0.13161 0.132587 0.130881 0.0722787 0.0879046 0.125855 0.0798449 0.0277327 0.135074 0.136049 0.130755 0.0870259 0.0562483 0.139077 0.0676905 0.0324785 0.138364 0.0692318 0.0578577 0.0455481 0.0977252 0.0715869 0.053042 0.094548 0.0547392 0.0910017 0.134962 0.0629282 0.138229 0.109354 0.144406 0.0863444 0.140152 0.140142 0.14014 0.132934 0.135832 0.0899903 0.144692 0.133059 0.132639 0.112082 0.140206 0.0835491 0.0621119 0.0979153 0.0816281 0.13381 0.052769 0.0349292 0.107957 0.0847257 0.081689 0.136055 0.102737 0.0530398 0.0934435 0.139344 0.0854647 0.085607 0.116426 0.103184 0.154972 0.0288951 0.0353032 0.111417 0.0956219 0.0942354 0.0589489 0.0306136 0.115734 0.126455 0.0360553 0.0251872 0.140034 0.112892 0.0844359 0.0737466 0.107017 0.0911456 0.131656 0.118341 0.0705608 0.108669 0.100854 0.119503 0.127661 0.105198 0.140212 0.140166 0.110189 0.0785525 0.136515 0.121896 0.0975286 0.0742552 0.123776 0.0792869 0.0773127 0.0866944 0.0866966 0.139502 0.0492343 0.140094 0.0441369 0.150134 0.0881737 0.127816 0.14019 0.137703 0.130208 0.0712211 0.111162 0.129639 0.0444124 0.123718 0.122405 0.0961291 0.1379 0.10611 0.0531996 0.139152 0.131117 0.100169 0.139258 0.0826619 0.0307158 0.0801005 0.112534 0.0567476 0.0778953 0.139733 0.0977772 0.138751 0.0884833 0.0838965 0.0522077 0.138887 0.103898 0.0629624 0.127274 0.122801 0.10049 0.137584 0.119401 0.132744 0.136876 0.0886346 0.125218 0.110279 0.095531 0.0930658 0.0922977 0.07003 0.128465 0.0857611 0.00757172 0.106945 0.0854392 0.078572 0.0768635 0.0392012 0.124111 0.126873 0.0879314 0.123527 0.096424 0.144725 0.112981 0.114752 0.0599605 0.134366 0.096616 0.0949553 0.0413683 0.088293 0.105245 0.140785 0.0751269 0.0862633 0.0396399 0.116161 0.0112643 0.112306 0.0773049 0.139684 0.0995888 0.0420996 0.0143388 0.132969 0.139456 0.0793142 0.108604 0.107195 0.12329 0.0659303 0.0250805 0.135834 0.072485 0.0925389 0.0532843 0.0957711 0.0294871 0.140078 0.0181836 0.139467 0.097922 0.12962 0.114506 0.0639556 0.0790448 0.113239 0.112068 0.129194 0.139177 0.139408 0.110609 0.0825534 0.140121 0.105694 0.106499 0.078099 0.0987121 0.135756 0.134687 0.0561687 0.0699265 0.0551431 0.13042 0.0120195 0.132162 0.116717 0.0436907 0.119761 0.0576931 0.13689 0.104257 0.0824284 0.0517496 0.0573587 0.0287547 0.111837 0.139258 0.0878631 0.0246683 0.0995491 0.10199 0.0133871 0.136768 0.127533 0.106188 0.0988008 0.110238 0.0877087 0.0724693 0.072237 0.122213 0.0626614 0.0461842 0.0818592 0.120634 0.136965 0.107961 0.0982396 0.0573539 0.0351103 0.111738 0.137313 0.071893 0.054247 0.13805 0.0524166 0.112432 0.116414 0.0717594 0.0382927 0.0687675 0.137814 0.137031 0.110795 0.122287 0.0365359 0.0713473 0.0157198 0.139674 0.13748 0.0736319 0.13848 0.0312411 0.104882 0.136617 0.127668 0.0736746 0.113717 0.138214 0.140082 0.121738 0.079981 0.131118 0.104586 0.113875 0.124406 0.0935177 0.0368661 0.138371 0.131433 0.140162 0.0823256 0.0581814 0.107238 0.0311901 0.00807794 0.12993 0.195526 0.055271 0.134593 0.128627 0.12802 0.106372 0.0791784 0.120131 0.124245 0.121927 0.0233158 0.0740453 0.138174 0.0929493 0.138494 0.101476 0.0899968 0.0900335 0.10227 0.04486 0.107606 0.140113 0.107025 0.0273101 0.0920859 0.13719 0.139621 0.140552 0.0980229 0.0768969 0.089208 0.134271 0.0325259 0.139035 0.080343 0.0355898 0.0398549 0.027244 0.083105 0.0681258 0.1148 0.119083 0.13837 0.0959112 0.0343668 0.0748061 0.124833 0.122162 0.085565 0.113144 0.0453667 0.139654 0.109264 0.103758 0.0480511 0.111434 0.0433017 0.103829 0.101648 0.139349 0.121507 0.046276 0.130488 0.140195 0.0727389 0.138093 0.0702511 0.0360401 0.132027 0.0791399 0.0939446 0.0634034 0.139498 0.15502 0.119796 0.0885062 0.12398 0.124315 0.075783 0.0765095 0.109661 0.114504 0.0845358 0.0770803 0.0848271 0.140201 0.109792 0.13403 0.0765217 0.0796973 0.138323 0.133499 0.122237 0.026767 0.122723 0.0858526 0.147223 0.0906552 0.109635 0.136796 0.138498 0.14012 0.129782 0.065036 0.136665 0.102373 0.0807421 0.113233 0.13214 0.0725091 0.0799513 0.136498 0.124319 0.101181 0.0701887 0.147056 0.114857 0.138619 0.0423636 0.0738796 0.0789944 0.137961 0.112314 0.0611826 0.129656 0.0620399 0.137135 0.0370386 0.111166 0.0942715 0.0861152 0.133504 0.0549555 0.144416 0.130141 0.133634 0.102132 0.0375875 0.137443 0.0987945 0.0228601 0.108011 0.128055 0.0526861 0.111182 0.125647 0.0810669 0.0900867 0.0640703 0.11547 0.139165 0.101353 0.138638 0.136568 0.0575502 0.126723 0.0635619 0.111756 0.0654298 0.136491 0.113727 0.11495 0.137001 0.115771 0.12313 0.127128 0.122221 0.122778 0.133074 0.0372735 0.0825024 0.125036 0.112007 0.128782 0.0414393 0.0858277 0.120965 0.0524966 0.0325384 0.0809872 0.116988 0.0626378 0.0616816 0.0463285 0.0279829 0.0897012 0.0562781 0.119622 0.0899249 0.126219 0.0230417 0.0308657 0.118364 0.0341038 0.0350016 0.137742 0.096746 0.0332222 0.142681 0.0760459 0.0700445 0.102091 0.131023 0.0813936 0.0395725 0.162971 0.0933607 0.13533 0.0845663 0.140097 0.172108 0.103788 0.0404957 0.0703862 0.112449 0.134013 0.0361664 0.169565 0.0390762 0.164856 0.11849 0.15351 0.138572 0.126955 0.0745344 0.126924 0.0845046 0.133446 0.112227 0.0289841 0.140059 0.0884379 0.0585051 0.0480621 0.0771899 0.13436 0.140045 0.134645 0.140121 0.0783286 0.0975398 0.0675031 0.139929 0.13256 0.0955001 0.117503 0.0753287 0.156022 0.0981262 0.111801 0.102811 0.115413 0.128721 0.128956 0.13684 0.126234 0.0941116 0.101635 0.0623691 0.126202 0.0894428 0.11678 0.0829361 0.123443 0.109365 0.0325695 0.132139 0.143892 0.0896258 0.135469 0.112933 0.137431 0.131697 0.0613978 0.126499 0.124422 0.0373415 0.0707414 0.0856802 0.135273 0.0997786 0.0695448 0.127695 0.0865346 0.0368336 0.0807496 0.0445162 0.0913296 0.137298 0.089867 0.127233 0.0891286 0.117079 0.0835117 0.104045 0.133591 0.0659209 0.190376 0.0783068 0.12807 0.0870307 0.0934649 0.140171 0.131518 0.132935 0.139617 0.0532818 0.132409 0.0582219 0.127991 0.0759914 0.138607 0.0383056 0.00971538 0.1032 0.0742616 0.0829105 0.139857 0.0121466 ) ; boundaryField { wings { type fixedValue; value uniform 0; } outlet { type freestream; freestreamValue uniform 0.14; value nonuniform List<scalar> 20 ( 0.130165 0.117886 0.137586 0.147768 0.138744 0.147748 0.134241 0.122208 0.135121 0.126472 0.426617 0.204857 0.13414 0.137906 0.220032 0.324478 0.336439 0.374981 0.13635 0.137103 ) ; } tunnel { type fixedValue; value uniform 0; } inlet { type freestream; freestreamValue uniform 0.14; value uniform 0.14; } defaultFaces { type empty; } } // ************************************************************************* //
[ "rlee32@gatech.edu" ]
rlee32@gatech.edu
5c76b0819646b683a1cb8b0e394492be3113f719
53337a542cdacc0d3a1b6480f4fabdcdce274b21
/src/lib/gfx/Texture.cpp
0659e35a45a06264511a6fa2e7d0e129f37d827b
[]
no_license
kalineh/tiger
7bd4026c6c6bdb17aa17f198f140e839aa53ec92
211f41744132b6ed3c49a595945934bebed83449
refs/heads/master
2016-09-06T05:13:16.043459
2013-01-27T04:35:24
2013-01-27T04:35:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,254
cpp
#include "Texture.h" #include <gm/gmBind.h> #include <gm/gmBindFuncGen.h> #include <common/Debug.h> #include <gl/glew.h> #include <il/il.h> #include <il/ilu.h> #include "TextureManager.h" namespace funk { Texture::Texture(): m_id(0), m_texSlot(-1), m_bManaged(true), m_bound(false) {;} Texture::Texture( int width, int height, TexParams params ) : m_bManaged(false), m_params(params), m_bound(false) { m_dimen = v2i(width, height); glGenTextures(1, &m_id); // Generate one texture glBindTexture(GL_TEXTURE_2D, m_id); // Bind the texture fbo_texture glTexImage2D(GL_TEXTURE_2D, 0, params.internalFormat, m_dimen.x, m_dimen.y, 0, params.format, params.dataType, 0); // Setup the basic texture parameters glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP ); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR ); // Unbind the texture glBindTexture(GL_TEXTURE_2D, 0); GLint err = glGetError(); CHECK( err == GL_NO_ERROR, "Creating FBO texture failed, GLerror: %d!", err ); } Texture::~Texture() { if ( m_bManaged ) TextureManager::Get()->ReleaseTexture(m_filename.c_str() ); // free from mem if ( m_id > 0 ) glDeleteTextures(1, &m_id); } void Texture::Init( const char * file ) { CHECK( m_id == 0, "Texture '%s' already initialized!", file ); m_filename = file; ILuint ih; ilGenImages(1, &ih); ilBindImage(ih); ilLoadImage(file); ILuint errorid = ilGetError() ; CHECK( errorid == IL_NO_ERROR, "Texture '%s' load error: %s", file, iluErrorString(errorid) ) ; m_dimen.x = (int)ilGetInteger( IL_IMAGE_WIDTH ); m_dimen.y = (int)ilGetInteger( IL_IMAGE_HEIGHT ); ASSERT(m_dimen.x > 0); ASSERT(m_dimen.y > 0); ILuint format = ilGetInteger ( IL_IMAGE_FORMAT ); ILuint dataType = ilGetInteger ( IL_IMAGE_TYPE ); // Find the GL image format and type GLint glFormat = GL_RGB + ( format - IL_RGB ); GLint glType = GL_BYTE + (dataType-IL_BYTE); int channels = ( glFormat == GL_RGBA ) ? 4: 3; glGenTextures( 1, &m_id ); glBindTexture( GL_TEXTURE_2D, m_id ); glTexImage2D(GL_TEXTURE_2D, 0, channels, m_dimen.x, m_dimen.y, 0, glFormat, glType, ilGetData() ); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); glBindTexture( GL_TEXTURE_2D, 0 ); ilDeleteImages(1, &ih); } void Texture::SetWrap( int uType, int vType ) { CHECK( m_bound, "Texture not bound!"); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, uType); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, vType); } void Texture::SetFilter( int minFilter, int magFilter ) { CHECK( m_bound, "Texture not bound!"); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, minFilter ); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, magFilter ); } void Texture::Init( const char * name, unsigned char * data, int width, int height, int bitsPerPixel ) { m_filename = name; CHECK( m_id == 0, "Texture already initialized!" ); CHECK( bitsPerPixel == 32 || bitsPerPixel == 24, "Texture data can only be 24 or 32-bit!"); m_dimen.x = width; m_dimen.y = height; glGenTextures( 1, &m_id ); glBindTexture( GL_TEXTURE_2D, m_id ); GLint glFormat = bitsPerPixel == 32 ? GL_RGBA : GL_RGB; glTexImage2D(GL_TEXTURE_2D, 0, 3, m_dimen.x, m_dimen.y, 0, glFormat, GL_UNSIGNED_BYTE, data ); } void Texture::Bind( int texSlot ) { CHECK( m_id != 0, "Texture not initialized!" ); WARN( !m_bound, "Texture already bound!"); glEnable( GL_TEXTURE_2D ); glActiveTexture(GL_TEXTURE0 + texSlot ); glBindTexture(GL_TEXTURE_2D, m_id ); m_texSlot = texSlot; m_bound = true; } void Texture::Unbind() { WARN( m_bound, "Texture not bound!"); glDisable( GL_TEXTURE_2D ); glActiveTexture(GL_TEXTURE0 + m_texSlot ); glBindTexture(GL_TEXTURE_2D, 0 ); m_texSlot = -1; m_bound = false; } void Texture::SubData( void* data, int width, int height, int offsetX, int offsetY, int level /*= 0*/ ) { CHECK( m_bound, "Texture not bound!"); assert( width+offsetX <= m_dimen.x && width >= 0 ); assert( height+offsetY <= m_dimen.y && height >= 0 ); glTexSubImage2D( GL_TEXTURE_2D, level, offsetX, offsetY, width, height, m_params.format, m_params.dataType, data ); } void Texture::ReadPixels( int x, int y, int width, int height, void* data ) { CHECK( m_bound, "Texture not bound!"); assert( width+x <= m_dimen.x && x >= 0 ); assert( height+y <= m_dimen.y && y >= 0 ); Bind(); glReadPixels( x, y, width, height, m_params.format, m_params.dataType, data ); Unbind(); } void Texture::GenMipMaps() { CHECK( m_bound, "Texture not bound!"); glHint(GL_GENERATE_MIPMAP_HINT, GL_NICEST); glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); } GM_REG_NAMESPACE(Texture) { GM_MEMFUNC_CONSTRUCTOR(Texture) { GM_CHECK_NUM_PARAMS(1); // from texture file if ( GM_IS_PARAM_STRING(0) ) { GM_STRING_PARAM( file, 0, "ERROR" ); StrongHandle<Texture> p = TextureManager::Get()->GetTex(file); GM_PUSH_USER_HANDLED( Texture, p.Get() ); return GM_OK; } // generate surface else if ( GM_IS_PARAM_VEC2(0) ) { GM_VEC2_PARAM( size, 0); GM_INT_PARAM( internalFormat, 1, RGBA8 ); GM_INT_PARAM( format, 2, RGBA ); GM_INT_PARAM( dataType, 3, UNSIGNED_BYTE ); // create texture TexParams params = TexParams((GLInternalFormat)internalFormat, (GLFormat)format, (GLDataType)dataType); StrongHandle<Texture> p = new Texture( int(size.x), int(size.y), params ); GM_PUSH_USER_HANDLED( Texture, p.Get() ); return GM_OK; } return GM_EXCEPTION; } GM_MEMFUNC_DECL(Filename) { GM_CHECK_NUM_PARAMS(0); GM_GET_THIS_PTR(Texture, ptr); a_thread->PushNewString( ptr->Filename().c_str(), ptr->Filename().size() ); return GM_OK; } GM_MEMFUNC_DECL(Width) { GM_CHECK_NUM_PARAMS(0); GM_GET_THIS_PTR(Texture, ptr); a_thread->PushInt(ptr->Sizei().x); return GM_OK; } GM_MEMFUNC_DECL(Height) { GM_CHECK_NUM_PARAMS(0); GM_GET_THIS_PTR(Texture, ptr); a_thread->PushInt(ptr->Sizei().y); return GM_OK; } GM_MEMFUNC_DECL(Dimen) { GM_CHECK_NUM_PARAMS(0); GM_GET_THIS_PTR(Texture, ptr); a_thread->PushVec2(v2( (float)ptr->Sizei().x, (float)ptr->Sizei().y)); return GM_OK; } GM_MEMFUNC_DECL(Bind) { GM_INT_PARAM( texSlot, 0, 0 ); GM_GET_THIS_PTR(Texture, ptr); ptr->Bind(texSlot); return GM_OK; } GM_GEN_MEMFUNC_VOID_VOID( Texture, Unbind ) GM_GEN_MEMFUNC_INT_VOID( Texture, Id ) GM_GEN_MEMFUNC_VOID_VOID( Texture, GenMipMaps ) GM_GEN_MEMFUNC_VOID_INT_INT( Texture, SetWrap ) GM_GEN_MEMFUNC_VOID_INT_INT( Texture, SetFilter ) } GM_REG_MEM_BEGIN(Texture) GM_REG_MEMFUNC( Texture, Bind ) GM_REG_MEMFUNC( Texture, Unbind ) GM_REG_MEMFUNC( Texture, Dimen ) GM_REG_MEMFUNC( Texture, Width ) GM_REG_MEMFUNC( Texture, Height ) GM_REG_MEMFUNC( Texture, Id ) GM_REG_MEMFUNC( Texture, GenMipMaps ) GM_REG_MEMFUNC( Texture, Filename ) GM_REG_MEMFUNC( Texture, SetWrap ) GM_REG_MEMFUNC( Texture, SetFilter ) GM_REG_HANDLED_DESTRUCTORS(Texture) GM_REG_MEM_END() GM_BIND_DEFINE(Texture) }
[ "kalin.eh@gmail.com" ]
kalin.eh@gmail.com
f14250161105ab25be4bcc64e6e91ff0a6e5351e
dcb85b9b6c093c93bca2a1d1549702c69d47a23e
/app/rdo_studio/src/tracer/tracer_result.cpp
7d1593f61617a5085f29bf923185a8ca8c91f58f
[ "MIT" ]
permissive
MachinaDeusEx/rdo_studio
c7c2657187099da9c2c15104df6735a337f01a0b
9c9c5df518a83ef8554b0bc1dc30a9e83ad40a4a
refs/heads/master
2020-08-04T14:38:35.726548
2015-12-06T17:40:02
2016-04-15T08:14:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,849
cpp
// ---------------------------------------------------------------------------- PCH #include "app/rdo_studio/pch/tracer_pch.h" // ----------------------------------------------------------------------- INCLUDES #include <boost/algorithm/string.hpp> #include <boost/lexical_cast.hpp> // ----------------------------------------------------------------------- SYNOPSIS #include "app/rdo_studio/src/tracer/tracer_result.h" #include "app/rdo_studio/src/tracer/tracer_values.h" // -------------------------------------------------------------------------------- using namespace rdo::gui::tracer; Result::Result(const QString& name, Kind kind, int id) : Serie(Serie::Kind::RESULT) , m_name(name) , m_kind(kind) , m_id(id) { setTitle(m_name); } Result::~Result() {} const QString& Result::getName() const { return m_name; } Result::Kind Result::getKind() const { return m_kind; } int Result::getID() const { return m_id; } void Result::getCaptions(std::vector<std::string>& captions, const int valueCount) const { switch (m_kind) { case Kind::WATCHQUANT: Serie::getCaptionsInt(captions, valueCount); break; case Kind::WATCHSTATE: Serie::getCaptionsBool(captions, valueCount); break; case Kind::WATCHPAR: case Kind::WATCHVALUE: Serie::getCaptionsDouble(captions, valueCount); break; default: NEVER_REACH_HERE; break; } } void Result::setValue(std::string& line, Time* const pTime, const int eventIndex) { double newValue; boost::algorithm::trim(line); if (m_kind != Kind::WATCHSTATE) { newValue = boost::lexical_cast<double>(line); } else { newValue = (line == "TRUE") ? 1 : 0; } Value* pNewValue = new Value(pTime, eventIndex, newValue); addValue(pNewValue); }
[ "drobus@gmail.com" ]
drobus@gmail.com
e9e495f9343246e413c775bf5b705776e4fe0a4f
efedfc9e45a2d8752dab16fe1768c296b7bbe6c2
/Engine/Source/script_logger/scriptlogger.cpp
6ee738c42414562b1f787967597d04e705c0f2d3
[ "MIT" ]
permissive
NuLL3rr0r/udk-native-logger
0f2e8db55c332839231267bf0d2731e0ed51d242
91dba58f0761b9cb98814b4dce461fbe58853948
refs/heads/master
2021-01-10T15:02:00.928801
2012-09-30T20:30:00
2012-09-30T20:30:00
47,872,372
0
0
null
null
null
null
UTF-8
C++
false
false
1,488
cpp
#include "scriptlogger.hpp" #include "log.hpp" using namespace UScriptLogger; ScriptLogger::ScriptLogger() { Log::Initialize("ScriptLogger"); NOTICE("ScriptLogger Initialized"); } ScriptLogger::~ScriptLogger() { } void ScriptLogger::Assert(const std::string &condition, const std::string &message, const std::string &channel, const std::string &source, const std::string &className, const std::string &stateName, const std::string &funcName) { } void ScriptLogger::Debug(const std::string &message, const std::string &channel, const std::string &source, const std::string &className, const std::string &stateName, const std::string &funcName) { } void ScriptLogger::Notice(const std::string &message, const std::string &channel, const std::string &source, const std::string &className, const std::string &stateName, const std::string &funcName) { NOTICE(message); } void ScriptLogger::Warn(const std::string &message, const std::string &channel, const std::string &source, const std::string &className, const std::string &stateName, const std::string &funcName) { } void ScriptLogger::Error(const std::string &message, const std::string &channel, const std::string &source, const std::string &className, const std::string &stateName, const std::string &funcName) { } void ScriptLogger::Fatal(const std::string &message, const std::string &channel, const std::string &source, const std::string &className, const std::string &stateName, const std::string &funcName) { }
[ "info@babaei.net" ]
info@babaei.net
dc38737e26a5356384ed2a0fb77bb323b35aef5c
3273254d14110fc3c050cbbb9a3ac98d9b198c22
/CarRx/Output.ino
71cf8022b53b3e7fb9f59c203bacca1417774047
[]
no_license
mactep8/RC_Car
d411f6d51a163075b8899f1bfddf0b7aada6e140
6d0411ab62a345d93909adcbc5819ae57068f666
refs/heads/master
2021-01-13T01:40:04.880459
2015-01-20T10:24:09
2015-01-20T10:24:09
26,306,146
0
0
null
null
null
null
UTF-8
C++
false
false
3,184
ino
#include "Output.h" volatile uint8_t cnt = 0; volatile uint8_t curr_chA=1; void Timers_Init() { TCCR1B = 0; //stop timer TCCR1A = 0; TCNT1 = 0; //setup TCCR1A = 0; TCCR1B = 0<<CS12 | 1<<CS11 | 0<<CS10; TIMSK1 = (1<<OCIE1A) | (1<<OCIE1B); // Разрешить прерывание по совпадению OCR1A = 0; OCR1B = 40000; /*cnt = 0; TCCR2B = 0; //stop timer TCCR2A = 0; TCNT2 = 0; //setup TCCR2A = 0; TCCR2A = 1<<WGM21; TCCR2B = 1<<CS22 | 1<<CS21 | 1<<CS20; TIMSK2 = 1<<OCIE2A; OCR2A = 155;*/ TCNT1 = 0; UpdateServos(); } /*ISR(TIMER2_COMPA_vect) { cnt++; if (cnt>=2){ // TCNT1=0; curr_chA = 0; OCR1A = TCNT1 + SET_TIME(curr_chA); ServoOn(curr_chA); cnt=0; #ifdef DEBUG // Serial.println("output data"); #endif dChannelsUpdate(); } }*/ ISR (TIMER1_COMPB_vect) { // TCNT1=0; curr_chA = 0; OCR1A = SET_TIME(curr_chA); ServoOn(curr_chA); dChannelsUpdate(); } ISR (TIMER1_COMPA_vect) { UpdateServos(); } void UpdateServos() { ServoOff(curr_chA); curr_chA++; if (curr_chA<ACHANNELS_COUNT) { OCR1A = TCNT1 + SET_TIME(curr_chA); ServoOn(curr_chA); } } void ServoOn(uint8_t ch) { switch(ch) { case 0: ACH0_on; break; case 1: ACH1_on; break; case 2: RSSI_on; break; case 10: DCH1_on; break; case 11: DCH2_on; break; case 12: DCH3_on; break; case 13: DCH4_on; break; } } void ServoOff(uint8_t ch) { switch(ch) { case 0: ACH0_off; break; case 1: ACH1_off; break; case 2: RSSI_off; break; case 10: DCH1_off; break; case 11: DCH2_off; break; case 12: DCH3_off; break; case 13: DCH4_off; break; } } void dChannelsUpdate() { uint8_t digi = dChannels; for(uint8_t i=0; i<DCHANNELS_COUNT; i++) { if (digi & 1) ServoOn(i+10); else ServoOff(i+10); digi >>= 1; } } void SetChannelValues() { aChannel[0] = ((tx_buf[2]<<8)|tx_buf[1]); aChannel[1] = ((tx_buf[4]<<8)|tx_buf[3]); dChannels = tx_buf[5]; if (aChannel[2] == 0) aChannel[2] = rfmGetRSSI(); else aChannel[2] = aChannel[2]*(1-LPF) + LPF * rfmGetRSSI();// <<2; #ifdef DEBUG /* Serial.print(aChannel[0]);Serial.print(" "); Serial.print(aChannel[1]);Serial.print(" "); Serial.print(aChannel[2]);Serial.println(" "); */ #endif } void InitOutput() { pinMode(3, OUTPUT); // RSSI pinMode(5, OUTPUT); // aChannel 1 pinMode(6, OUTPUT); // aChannel 2 pinMode(7, OUTPUT); // dChannel 1 pinMode(8, OUTPUT); // dChannel 2 pinMode(9, OUTPUT); // dChannel 3 pinMode(10, OUTPUT); // dChannel 4 pinMode(11, INPUT); // BUTTON digitalWrite(11, HIGH); pinMode(Green_LED, OUTPUT); pinMode(Red_LED, OUTPUT); } void SetFailsafe() { FsEn = true; // Red_LED_ON // Red_LED_OFF if (IsPresetFS()) { Red_LED_ON; LoadFS(); } } void ResetFailsafe() { FsEn = false; Red_LED_OFF; } uint32_t lastFSTime = 0; void PresetFailsafe() { uint32_t time = millis(); if (time - lastFSTime > 10000) { Serial.println(" PresetFailsafe "); lastFSTime = time; if (IsPresetFS()) { ResetFS(); Green_LED_OFF } else { SaveFS(); Green_LED_ON } } }
[ "mactep8@users.noreply.github.com" ]
mactep8@users.noreply.github.com
cccfb6c92b3e8f3a05cd2fbb0d867a0983a99071
8e966c3ac3bdee2412b40685dd4a0fc055e0b97e
/src/dxvk/dxvk_buffer.h
9e8923879ce07db8ca6d8aedfb25c6d28e5e14aa
[ "LicenseRef-scancode-warranty-disclaimer", "Zlib" ]
permissive
shaunstanislauslau/dxvk
8796c519a3ea1d0f79cb21d2c6359e9f22e7c60f
1da23755b71f948b3cb6350fe180c0762ff48073
refs/heads/master
2021-05-10T13:13:53.734659
2018-01-22T13:31:53
2018-01-22T13:31:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,664
h
#pragma once #include "dxvk_buffer_res.h" namespace dxvk { /** * \brief Virtual buffer resource * * A simple buffer resource that stores linear, * unformatted data. Can be accessed by the host * if allocated on an appropriate memory type. */ class DxvkBuffer : public RcObject { public: DxvkBuffer( DxvkDevice* device, const DxvkBufferCreateInfo& createInfo, VkMemoryPropertyFlags memoryType); /** * \brief Buffer properties * \returns Buffer properties */ const DxvkBufferCreateInfo& info() const { return m_info; } /** * \brief Memory type flags * * Use this to determine whether a * buffer is mapped to host memory. * \returns Vulkan memory flags */ VkMemoryPropertyFlags memFlags() const { return m_memFlags; } /** * \brief Map pointer * * If the buffer has been created on a host-visible * memory type, the buffer memory is mapped and can * be accessed by the host. * \param [in] offset Byte offset into mapped region * \returns Pointer to mapped memory region */ void* mapPtr(VkDeviceSize offset) const { return m_physSlice.mapPtr(offset); } /** * \brief Checks whether the buffer is in use * * Returns \c true if the underlying buffer resource * is in use. If it is, it should not be accessed by * the host for reading or writing, but reallocating * the buffer is a valid strategy to overcome this. * \returns \c true if the buffer is in use */ bool isInUse() const { return m_physSlice.resource()->isInUse(); } /** * \brief Underlying buffer resource * * Use this for lifetime tracking. * \returns The resource object */ Rc<DxvkResource> resource() const { return m_physSlice.resource(); } /** * \brief Physical buffer slice * * Retrieves a slice into the physical * buffer which backs this buffer. * \returns The backing slice */ DxvkPhysicalBufferSlice slice() const { return m_physSlice; } /** * \brief Physical buffer sub slice * * Retrieves a sub slice into the backing buffer. * \param [in] offset Offset into the buffer * \param [in] length Length of the slice * \returns The sub slice */ DxvkPhysicalBufferSlice subSlice(VkDeviceSize offset, VkDeviceSize length) const { return m_physSlice.subSlice(offset, length); } /** * \brief Replaces backing resource * * Replaces the underlying buffer and implicitly marks * any buffer views using this resource as dirty. Do * not call this directly as this is called implicitly * by the context's \c invalidateBuffer method. * \param [in] slice The new backing resource */ void rename( const DxvkPhysicalBufferSlice& slice); /** * \brief Allocates new physical resource * * This method must not be called from multiple threads * simultaneously, but it can be called in parallel with * \ref rename and other methods of this class. * \returns The new backing buffer slice */ DxvkPhysicalBufferSlice allocPhysicalSlice(); private: DxvkDevice* m_device; DxvkBufferCreateInfo m_info; VkMemoryPropertyFlags m_memFlags; DxvkPhysicalBufferSlice m_physSlice; // TODO maybe align this to a cache line in order // to avoid false sharing once CSMT is implemented VkDeviceSize m_physBufferId = 0; VkDeviceSize m_physSliceId = 0; VkDeviceSize m_physSliceCount = 1; std::array<Rc<DxvkPhysicalBuffer>, 2> m_physBuffers; Rc<DxvkPhysicalBuffer> allocPhysicalBuffer( VkDeviceSize sliceCount) const; }; /** * \brief Buffer view * * Allows the application to interpret buffer * contents like formatted pixel data. These * buffer views are used as texel buffers. */ class DxvkBufferView : public DxvkResource { public: DxvkBufferView( const Rc<vk::DeviceFn>& vkd, const Rc<DxvkBuffer>& buffer, const DxvkBufferViewCreateInfo& info); ~DxvkBufferView(); /** * \brief Buffer view handle * \returns Buffer view handle */ VkBufferView handle() const { return m_view; } /** * \brief Buffer view properties * \returns Buffer view properties */ const DxvkBufferViewCreateInfo& info() const { return m_info; } /** * \brief Underlying buffer object * \returns Underlying buffer object */ const DxvkBufferCreateInfo& bufferInfo() const { return m_buffer->info(); } /** * \brief Backing resource * \returns Backing resource */ Rc<DxvkResource> resource() const { return m_buffer->resource(); } /** * \brief Underlying buffer slice * \returns Slice backing the view */ DxvkPhysicalBufferSlice slice() const { return m_buffer->subSlice( m_info.rangeOffset, m_info.rangeLength); } private: Rc<vk::DeviceFn> m_vkd; Rc<DxvkBuffer> m_buffer; DxvkBufferViewCreateInfo m_info; VkBufferView m_view; void createBufferView(); void destroyBufferView(); }; /** * \brief Buffer slice * * Stores the buffer and a sub-range of the buffer. * Slices are considered equal if the buffer and * the buffer range are the same. */ class DxvkBufferSlice { public: DxvkBufferSlice() { } DxvkBufferSlice( const Rc<DxvkBuffer>& buffer, VkDeviceSize rangeOffset, VkDeviceSize rangeLength) : m_buffer(buffer), m_offset(rangeOffset), m_length(rangeLength) { } explicit DxvkBufferSlice(const Rc<DxvkBuffer>& buffer) : DxvkBufferSlice(buffer, 0, buffer->info().size) { } size_t offset() const { return m_offset; } size_t length() const { return m_length; } /** * \brief Underlying buffer * \returns The virtual buffer */ Rc<DxvkBuffer> buffer() const { return m_buffer; } /** * \brief Buffer info * * Retrieves the properties of the underlying * virtual buffer. Should not be used directly * by client APIs. * \returns Buffer properties */ const DxvkBufferCreateInfo& bufferInfo() const { return m_buffer->info(); } /** * \brief Buffer sub slice * * Takes a sub slice from this slice. * \param [in] offset Sub slice offset * \param [in] length Sub slice length * \returns The sub slice object */ DxvkBufferSlice subSlice(VkDeviceSize offset, VkDeviceSize length) const { return DxvkBufferSlice(m_buffer, offset, length); } /** * \brief Checks whether the slice is valid * * A buffer slice that does not point to any virtual * buffer object is considered undefined and cannot * be used for any operations. * \returns \c true if the slice is defined */ bool defined() const { return m_buffer != nullptr; } /** * \brief Physical slice * * Retrieves the physical slice that currently * backs the virtual slice. This may change * when the virtual buffer gets invalidated. * \returns The physical buffer slice */ DxvkPhysicalBufferSlice physicalSlice() const { return m_buffer->subSlice(m_offset, m_length); } /** * \brief Pointer to mapped memory region * * \param [in] offset Offset into the slice * \returns Pointer into mapped buffer memory */ void* mapPtr(VkDeviceSize offset) const { return m_buffer->mapPtr(m_offset + offset); } /** * \brief Checks whether two slices are equal * * Two slices are considered equal if they point to * the same memory region within the same buffer. * \param [in] other The slice to compare to * \returns \c true if the two slices are the same */ bool matches(const DxvkBufferSlice& other) const { return this->m_buffer == other.m_buffer && this->m_offset == other.m_offset && this->m_length == other.m_length; } private: Rc<DxvkBuffer> m_buffer = nullptr; VkDeviceSize m_offset = 0; VkDeviceSize m_length = 0; }; }
[ "philip.rebohle@tu-dortmund.de" ]
philip.rebohle@tu-dortmund.de
a0b0aeaf3fdc17048501058cc7d0fd4fc770e60a
83ceea39302102c1cca4634267d7b0dc56c8624c
/Log.h
7663202f2148d51786ec0fc692b1ce6e61c412d8
[]
no_license
jrz371/SDL-3D-Renderer
e553a0f24ae585793755a5daa3a5eb47e8e43c02
ae7428bc4cedb3b062ada68012536c73f124b2b1
refs/heads/master
2021-09-27T07:53:23.662338
2017-08-20T15:08:13
2017-08-20T15:08:13
100,865,162
3
3
null
2021-09-14T12:29:05
2017-08-20T13:59:01
C++
UTF-8
C++
false
false
389
h
#pragma once #include <fstream> #include <string> using namespace std; enum LOG_TYPE { ERROR = 0, WARNING = 1, MESSAGE = 2 }; //simple logger for putting messages in a debug txt file class Log { public: //opens the file static void Init(); //adds text to file static void SendMessage(string message, LOG_TYPE level); //closes file static void Close(); private: protected: };
[ "joshuakennedy102@gmail.com" ]
joshuakennedy102@gmail.com
b8af8cfbb7c3b9092b80f9282f71975eee0ef242
271cbe3a1c79ad1286e330493ad97b62e100c681
/engine/apps/util.h
f7428737dbd6049ef7debe2958c0ec6647216355
[ "NCSA", "LicenseRef-scancode-unknown-license-reference" ]
permissive
nilsoberg2/rvrmeander
61695e669bf4602d5e9bf6f5ed92d9120f2ce6b3
9732129e223eb25e9555298bc285f7daff7b6bc2
refs/heads/master
2021-05-31T17:21:11.202511
2016-04-25T16:12:54
2016-04-25T16:12:54
56,606,302
1
1
null
null
null
null
UTF-8
C++
false
false
242
h
#ifndef __UTIL_H____________________________20101003223535__ #define __UTIL_H____________________________20101003223535__ #include <string> std::string ToLower(std::string in); #endif//__UTIL_H____________________________20101003223535__
[ "nilsoberg@gmail.com" ]
nilsoberg@gmail.com
1fbaff9b3706e072e346522f36b91168dc5417fd
8e6353fc1f7f2b186964417c7173e62fd435c0cb
/CL11-2/T31MANDW/COMPL.H
27575d8ffc5b43d341d3ff91e6d96272436c38a0
[]
no_license
Sleeping-Monkey/School
1fefc34082ad3d43ebd40c355212906d5ed7cd89
28cd2e0e41e0b5fbaafb8a3b7c60e2dbbe8f1b68
refs/heads/master
2021-06-09T20:21:47.479289
2021-05-24T09:02:49
2021-05-24T09:02:49
168,291,800
0
0
null
null
null
null
UTF-8
C++
false
false
3,535
h
/*Romanova Polina 11-2 25.09.2014*/ #include <glut.h> #include <stdio.h> #include <math.h> #include <iostream> #include <time.h> #define byte unsigned char #define ys 2.0 #define xs 2.0 #define H 500 #define W 500 using namespace std; double SyncTime; void Timer(void) { long t; static long StartTime = -1; t = clock(); if(StartTime == -1) StartTime = t; SyncTime = (double)(t - StartTime) / CLOCKS_PER_SEC; } struct Compl { double Re, Im; Compl() {} Compl(double a) : Re(a), Im(0) {} Compl(double a, double b) : Re(a), Im(b) {} Compl operator+(const Compl & z) { return Compl(Re + z.Re, Im + z.Im); } Compl operator*(const Compl & z) { return Compl(Re * z.Re - Im * z.Im, Re * z.Im + Im * z.Re); } double operator!(void) { return sqrt(Re * Re + Im * Im); } int Julia(const Compl &C) { int n = 0; Compl z(Re, Im); while(n < 254 && !z <= 2) { z = z * z + C; n++; } return n; } }; template <class T1, class T2> T1 Lepr(T1 A, T1 B, T2 t) { return (1 - t) * A + B * t; } struct Frame { //const int W, H; byte StartImagew[H][W][4], FinishImagew[H][W][4], TmpImagew[H][W][4]; int Transision_Frames, FrameT; Frame(int Time) : Transision_Frames(Time), FrameT(0) { for (int x = 0; x < W; x++) { for (int y = 0; y < H; y++) { double xc = 2 * xs * x / W - xs, yc = 2 * ys * y / H - ys; Compl z = Compl(xc, yc); int n = z.Julia(0.4); PutPixel(x, y, n, n * n, n * n * n); n = z.Julia(0.4 * sin(SyncTime * 10)); PutPixelFinish(x, y, n, n * n, n * n * n); } } } void Draw(void) { glDrawPixels(W, H, GL_BGRA_EXT, GL_UNSIGNED_BYTE, TmpImagew); } void Calculate(double c) { for (int x = 0; x < W; x++) { for (int y = 0; y < H; y++) { double xc = 2 * xs * x / W - xs, yc = 2 * ys * y / H - ys; Compl z = Compl(xc, yc); int n = z.Julia(c); PutPixelFinish(x, y, n * n * n, n * n * n, n * n * n); } } } void CalculateTmp(void) { for (int x = 0; x < W; x++) { for (int y = 0; y < H; y++) { byte rn = Lepr<byte, double>(StartImagew[y][x][0], FinishImagew[y][x][0], 1.0 * FrameT / Transision_Frames); byte gn = Lepr<byte, double>(StartImagew[y][x][1], FinishImagew[y][x][1], 1.0 * FrameT / Transision_Frames); byte bn = Lepr<byte, double>(StartImagew[y][x][2], FinishImagew[y][x][2], 1.0 * FrameT / Transision_Frames); PutPixelTmp(x, y, rn, gn, bn); } } FrameT++; if (FrameT == Transision_Frames) { Swap(); FrameT = 0; Calculate(sin(SyncTime) + SyncTime * 0.3); } } void PutPixel(int x, int y, byte r, byte g, byte b) { StartImagew[y][x][0] = r; StartImagew[y][x][1] = g; StartImagew[y][x][2] = b; } void PutPixelFinish(int x, int y, byte r, byte g, byte b) { FinishImagew[y][x][0] = r; FinishImagew[y][x][1] = g; FinishImagew[y][x][2] = b; } void PutPixelTmp(int x, int y, byte r, byte g, byte b) { TmpImagew[y][x][0] = r; TmpImagew[y][x][1] = g; TmpImagew[y][x][2] = b; } void Swap(void) { for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { for (int k = 0; k < 4; k++) { TmpImagew[i][j][k] = FinishImagew[i][j][k]; FinishImagew[i][j][k] = StartImagew[i][j][k]; StartImagew[i][j][k] = TmpImagew[i][j][k]; } } } } }; void Display(void);
[ "appa.romanova@yandex.ru" ]
appa.romanova@yandex.ru
35e0b29a1b7a653ddc8680155d7e191918579136
3ca76cceaad27d8e6e8cd2da2f6c1ebd781df4ab
/src/humanoids/humanoids.hpp
954ad94003c1772f2a948ed085435ca99f6d6721
[]
no_license
ibrahima/trajopt
fc81e2c97a5c5121b66a433c791bace2ee9d52c6
b4e023b6a11ec1a0531862b4ae5f2329a2d5ef87
refs/heads/master
2021-01-18T14:36:15.821428
2013-01-16T03:38:36
2013-01-16T03:38:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
556
hpp
#pragma once #include <Eigen/Core> #include <trajopt/common.hpp> namespace trajopt { using Eigen::MatrixX2d; struct ZMP: public Constraint, public Plotter { RobotAndDOFPtr m_rad; VarVector m_vars; MatrixX2d m_ab, m_pts; VectorXd m_c; ZMP(RobotAndDOFPtr rad, const MatrixX2d& hullpts, const VarVector& vars); DblVec value(const DblVec&); ConvexConstraintsPtr convex(const DblVec&, Model* model); void Plot(const DblVec& x, OR::EnvironmentBase& env, std::vector<OR::GraphHandlePtr>& handles); ConstraintType type() {return INEQ;} }; }
[ "john.d.schulman@gmail.com" ]
john.d.schulman@gmail.com
57f7f8c43155a6229c1eafb86600629b573fd04c
06aacff15fee2fad470876f4d4bf6fac1d9c6d60
/src/compiler/serializer-for-background-compilation.h
549d538d89d82eb22f758b1e7578cabfb786e300
[ "BSD-3-Clause", "SunPro", "bzip2-1.0.6", "Apache-2.0" ]
permissive
zanywhale/v8
64dea619a28b4de8f35228a815c1b7ef1c9ec615
878ccb33bd3cf0e6dc018ff8d15843f585ac07be
refs/heads/master
2020-05-26T10:04:34.573077
2019-05-23T07:47:44
2019-05-23T07:52:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
12,613
h
// Copyright 2018 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef V8_COMPILER_SERIALIZER_FOR_BACKGROUND_COMPILATION_H_ #define V8_COMPILER_SERIALIZER_FOR_BACKGROUND_COMPILATION_H_ #include "src/base/optional.h" #include "src/compiler/access-info.h" #include "src/handles/handles.h" #include "src/handles/maybe-handles.h" #include "src/utils.h" #include "src/zone/zone-containers.h" namespace v8 { namespace internal { namespace interpreter { class BytecodeArrayIterator; } // namespace interpreter class BytecodeArray; class FeedbackVector; class LookupIterator; class NativeContext; class ScriptContextTable; class SharedFunctionInfo; class SourcePositionTableIterator; class Zone; namespace compiler { #define CLEAR_ENVIRONMENT_LIST(V) \ V(Abort) \ V(CallRuntime) \ V(CallRuntimeForPair) \ V(CreateBlockContext) \ V(CreateEvalContext) \ V(CreateFunctionContext) \ V(Debugger) \ V(PopContext) \ V(PushContext) \ V(ResumeGenerator) \ V(ReThrow) \ V(StaContextSlot) \ V(StaCurrentContextSlot) \ V(SuspendGenerator) \ V(SwitchOnGeneratorState) \ V(Throw) #define CLEAR_ACCUMULATOR_LIST(V) \ V(Add) \ V(AddSmi) \ V(BitwiseAnd) \ V(BitwiseAndSmi) \ V(BitwiseNot) \ V(BitwiseOr) \ V(BitwiseOrSmi) \ V(BitwiseXor) \ V(BitwiseXorSmi) \ V(CloneObject) \ V(CreateArrayFromIterable) \ V(CreateArrayLiteral) \ V(CreateEmptyArrayLiteral) \ V(CreateEmptyObjectLiteral) \ V(CreateMappedArguments) \ V(CreateObjectLiteral) \ V(CreateRestParameter) \ V(CreateUnmappedArguments) \ V(Dec) \ V(DeletePropertySloppy) \ V(DeletePropertyStrict) \ V(Div) \ V(DivSmi) \ V(Exp) \ V(ExpSmi) \ V(ForInContinue) \ V(ForInEnumerate) \ V(ForInNext) \ V(ForInStep) \ V(GetTemplateObject) \ V(Inc) \ V(LdaContextSlot) \ V(LdaCurrentContextSlot) \ V(LdaImmutableContextSlot) \ V(LdaImmutableCurrentContextSlot) \ V(LogicalNot) \ V(Mod) \ V(ModSmi) \ V(Mul) \ V(MulSmi) \ V(Negate) \ V(SetPendingMessage) \ V(ShiftLeft) \ V(ShiftLeftSmi) \ V(ShiftRight) \ V(ShiftRightLogical) \ V(ShiftRightLogicalSmi) \ V(ShiftRightSmi) \ V(Sub) \ V(SubSmi) \ V(TestEqual) \ V(TestEqualStrict) \ V(TestGreaterThan) \ V(TestGreaterThanOrEqual) \ V(TestInstanceOf) \ V(TestLessThan) \ V(TestLessThanOrEqual) \ V(TestNull) \ V(TestReferenceEqual) \ V(TestTypeOf) \ V(TestUndefined) \ V(TestUndetectable) \ V(ToBooleanLogicalNot) \ V(ToName) \ V(ToNumber) \ V(ToNumeric) \ V(ToString) \ V(TypeOf) #define UNCONDITIONAL_JUMPS_LIST(V) \ V(Jump) \ V(JumpConstant) \ V(JumpLoop) #define CONDITIONAL_JUMPS_LIST(V) \ V(JumpIfFalse) \ V(JumpIfFalseConstant) \ V(JumpIfJSReceiver) \ V(JumpIfJSReceiverConstant) \ V(JumpIfNotNull) \ V(JumpIfNotNullConstant) \ V(JumpIfNotUndefined) \ V(JumpIfNotUndefinedConstant) \ V(JumpIfNull) \ V(JumpIfNullConstant) \ V(JumpIfToBooleanFalse) \ V(JumpIfToBooleanFalseConstant) \ V(JumpIfToBooleanTrue) \ V(JumpIfToBooleanTrueConstant) \ V(JumpIfTrue) \ V(JumpIfTrueConstant) \ V(JumpIfUndefined) \ V(JumpIfUndefinedConstant) #define IGNORED_BYTECODE_LIST(V) \ V(CallNoFeedback) \ V(LdaNamedPropertyNoFeedback) \ V(StackCheck) \ V(StaNamedPropertyNoFeedback) \ V(ThrowReferenceErrorIfHole) \ V(ThrowSuperAlreadyCalledIfNotHole) \ V(ThrowSuperNotCalledIfHole) #define SUPPORTED_BYTECODE_LIST(V) \ V(CallAnyReceiver) \ V(CallProperty) \ V(CallProperty0) \ V(CallProperty1) \ V(CallProperty2) \ V(CallUndefinedReceiver) \ V(CallUndefinedReceiver0) \ V(CallUndefinedReceiver1) \ V(CallUndefinedReceiver2) \ V(CallWithSpread) \ V(Construct) \ V(ConstructWithSpread) \ V(CreateClosure) \ V(ExtraWide) \ V(GetSuperConstructor) \ V(Illegal) \ V(LdaConstant) \ V(LdaFalse) \ V(LdaGlobal) \ V(LdaGlobalInsideTypeof) \ V(LdaKeyedProperty) \ V(LdaLookupGlobalSlot) \ V(LdaLookupGlobalSlotInsideTypeof) \ V(LdaNamedProperty) \ V(LdaNull) \ V(Ldar) \ V(LdaSmi) \ V(LdaTheHole) \ V(LdaTrue) \ V(LdaUndefined) \ V(LdaZero) \ V(Mov) \ V(Return) \ V(StaGlobal) \ V(StaInArrayLiteral) \ V(StaKeyedProperty) \ V(StaNamedOwnProperty) \ V(StaNamedProperty) \ V(Star) \ V(TestIn) \ V(Wide) \ CLEAR_ENVIRONMENT_LIST(V) \ CLEAR_ACCUMULATOR_LIST(V) \ CONDITIONAL_JUMPS_LIST(V) \ UNCONDITIONAL_JUMPS_LIST(V) \ IGNORED_BYTECODE_LIST(V) class JSHeapBroker; template <typename T> struct HandleComparator { bool operator()(const Handle<T>& lhs, const Handle<T>& rhs) const { return lhs.address() < rhs.address(); } }; struct FunctionBlueprint { Handle<SharedFunctionInfo> shared; Handle<FeedbackVector> feedback_vector; bool operator<(const FunctionBlueprint& other) const { // A feedback vector is never used for more than one SFI, so it can // be used for strict ordering of blueprints. DCHECK_IMPLIES(feedback_vector.equals(other.feedback_vector), shared.equals(other.shared)); return HandleComparator<FeedbackVector>()(feedback_vector, other.feedback_vector); } }; class CompilationSubject { public: explicit CompilationSubject(FunctionBlueprint blueprint) : blueprint_(blueprint) {} CompilationSubject(Handle<JSFunction> closure, Isolate* isolate); FunctionBlueprint blueprint() const { return blueprint_; } MaybeHandle<JSFunction> closure() const { return closure_; } private: FunctionBlueprint blueprint_; MaybeHandle<JSFunction> closure_; }; using ConstantsSet = ZoneSet<Handle<Object>, HandleComparator<Object>>; using MapsSet = ZoneSet<Handle<Map>, HandleComparator<Map>>; using BlueprintsSet = ZoneSet<FunctionBlueprint>; class Hints { public: explicit Hints(Zone* zone); const ConstantsSet& constants() const; const MapsSet& maps() const; const BlueprintsSet& function_blueprints() const; void AddConstant(Handle<Object> constant); void AddMap(Handle<Map> map); void AddFunctionBlueprint(FunctionBlueprint function_blueprint); void Add(const Hints& other); void Clear(); bool IsEmpty() const; private: ConstantsSet constants_; MapsSet maps_; BlueprintsSet function_blueprints_; }; using HintsVector = ZoneVector<Hints>; // The SerializerForBackgroundCompilation makes sure that the relevant function // data such as bytecode, SharedFunctionInfo and FeedbackVector, used by later // optimizations in the compiler, is copied to the heap broker. class SerializerForBackgroundCompilation { public: SerializerForBackgroundCompilation(JSHeapBroker* broker, CompilationDependencies* dependencies, Zone* zone, Handle<JSFunction> closure, bool collect_source_positions); Hints Run(); // NOTE: Returns empty for an already-serialized function. class Environment; private: SerializerForBackgroundCompilation(JSHeapBroker* broker, CompilationDependencies* dependencies, Zone* zone, CompilationSubject function, base::Optional<Hints> new_target, const HintsVector& arguments, bool collect_source_positions); void TraverseBytecode(); #define DECLARE_VISIT_BYTECODE(name, ...) \ void Visit##name(interpreter::BytecodeArrayIterator* iterator); SUPPORTED_BYTECODE_LIST(DECLARE_VISIT_BYTECODE) #undef DECLARE_VISIT_BYTECODE void ProcessCallOrConstruct(Hints callee, base::Optional<Hints> new_target, const HintsVector& arguments, FeedbackSlot slot, bool with_spread = false); void ProcessCallVarArgs(interpreter::BytecodeArrayIterator* iterator, ConvertReceiverMode receiver_mode, bool with_spread = false); void ProcessJump(interpreter::BytecodeArrayIterator* iterator); void MergeAfterJump(interpreter::BytecodeArrayIterator* iterator); void ProcessKeyedPropertyAccess(Hints const& receiver, Hints const& key, FeedbackSlot slot, AccessMode mode); void ProcessNamedPropertyAccess(interpreter::BytecodeArrayIterator* iterator, AccessMode mode); void ProcessNamedPropertyAccess(Hints const& receiver, NameRef const& name, FeedbackSlot slot, AccessMode mode); GlobalAccessFeedback const* ProcessFeedbackForGlobalAccess(FeedbackSlot slot); NamedAccessFeedback const* ProcessFeedbackMapsForNamedAccess( const MapHandles& maps, AccessMode mode, NameRef const& name); ElementAccessFeedback const* ProcessFeedbackMapsForElementAccess( const MapHandles& maps, AccessMode mode); void ProcessFeedbackForPropertyAccess(FeedbackSlot slot, AccessMode mode, base::Optional<NameRef> static_name); void ProcessMapForNamedPropertyAccess(MapRef const& map, NameRef const& name); Hints RunChildSerializer(CompilationSubject function, base::Optional<Hints> new_target, const HintsVector& arguments, bool with_spread); JSHeapBroker* broker() const { return broker_; } CompilationDependencies* dependencies() const { return dependencies_; } Zone* zone() const { return zone_; } // The following flag is initialized from OptimizedCompilationInfo's // {is_source_positions_enabled}. bool collect_source_positions() const { return collect_source_positions_; } Environment* environment() const { return environment_; } JSHeapBroker* const broker_; CompilationDependencies* const dependencies_; Zone* const zone_; bool const collect_source_positions_; Environment* const environment_; ZoneUnorderedMap<int, Environment*> stashed_environments_; }; } // namespace compiler } // namespace internal } // namespace v8 #endif // V8_COMPILER_SERIALIZER_FOR_BACKGROUND_COMPILATION_H_
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
455f82e5555680b0bbea9a902b298a224f5b46bc
2feb7b99e4b0c9d74a8ac7d365b7f7d7722c58cc
/Introduccion/mayor menor 3 numeros.cpp
c7a06af19da6d3645ad5f9e6c3ea23ec1e9bc02e
[]
no_license
AlexeiVazquez/Funciones
ff289c2f43c22f3fffc12ad3a7536917f19f004b
9beaf150785b8fe2b3775d16d01c7bf3ae20c551
refs/heads/main
2023-03-07T19:31:02.699340
2021-02-26T22:14:25
2021-02-26T22:14:25
342,694,254
1
0
null
null
null
null
UTF-8
C++
false
false
484
cpp
#include<iostream> int max(int,int); using namespace std; int main(){ int a,b,d; cout<<"Introduzca el valor del primer numero: "<<endl; cin>>a; cout<<"Introduzca el valor del segundo numero: "<<endl; cin>>b; cout<<"Introduzca el valor del tercer numero: "<<endl; cin>>d; int max1=max(a,b); int max2=max(max1,d); cout<<"El numero mayor es: "<<max2<<endl; return 0; } int max(int a, int b){ int c; if(a>b){ c=a; } else { c=b; } return c; }
[ "noreply@github.com" ]
noreply@github.com
2c915e6fdd43c26249e381c822ce1ba18e9cc5e4
64ddbe223960a7b054e124741314e6bc8a8ccd5a
/Prácticas/Práctica 3/19082019/pro2_3.cpp
81232ec8c2d54496710cdf7265499ee1311150ab
[]
no_license
eerick1997/Sistemas-distribuidos
04b35613a40d2a70d7867c47ddfd4ddb8fac88a7
23a940ad0eaf5f618f5cf9450f40f18950a2e746
refs/heads/master
2020-06-30T06:38:28.762451
2019-11-25T17:55:57
2019-11-25T17:55:57
200,757,177
0
0
null
null
null
null
UTF-8
C++
false
false
135
cpp
#include "Fecha.h" #include <iostream> using namespace std; int main(){ Fecha a(19, 8, 2019); cout << a.convierte() << endl; }
[ "noreply@github.com" ]
noreply@github.com
7042960a72608091371702368fa9a7c64c50df39
c32ee8ade268240a8064e9b8efdbebfbaa46ddfa
/Libraries/m2sdk/C_Human2CarWrapper.h
45507becd61011b2b9276ebfcef1c47fbc17f3e2
[]
no_license
hopk1nz/maf2mp
6f65bd4f8114fdeb42f9407a4d158ad97f8d1789
814cab57dc713d9ff791dfb2a2abeb6af0e2f5a8
refs/heads/master
2021-03-12T23:56:24.336057
2015-08-22T13:53:10
2015-08-22T13:53:10
41,209,355
19
21
null
2015-08-31T05:28:13
2015-08-22T13:56:04
C++
UTF-8
C++
false
false
372
h
// auto-generated file (rttidump-exporter by h0pk1nz) #pragma once #include <I_Human2WrapperBase.h> /** C_Human2CarWrapper (VTable=0x01E74960) */ class C_Human2CarWrapper : public I_Human2WrapperBase { public: virtual void vfn_0001_192B64D9() = 0; virtual void vfn_0002_192B64D9() = 0; virtual void vfn_0003_192B64D9() = 0; virtual void vfn_0004_192B64D9() = 0; };
[ "hopk1nz@gmail.com" ]
hopk1nz@gmail.com
7a0833a3505ef5507933ac9b0a71e7be6f4cae6e
0d4e28f7e9d961e45d32a4735ad7c1f76bbda34a
/ocs2_ocs2/include/ocs2_ocs2/upper_level_op/UpperLevelConstraints.h
6ed98b737d50dc0bc8e9a440f2febadf14d9a647
[ "BSD-3-Clause" ]
permissive
RoboMark9/ocs2
a4fc0c215ccb3a86afeffe93b6a67fb0d9dd9450
b037d819c9a02a674de9badb628b32646ce11d6a
refs/heads/main
2023-08-29T15:20:07.117885
2021-10-20T13:09:37
2021-10-20T13:09:37
453,286,119
1
0
BSD-3-Clause
2022-01-29T03:30:28
2022-01-29T03:30:27
null
UTF-8
C++
false
false
4,106
h
/****************************************************************************** Copyright (c) 2017, Farbod Farshidian. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************/ #pragma once #include <ocs2_frank_wolfe/NLP_Constraints.h> namespace ocs2 { /** * This class is an interface to a NLP constraints. */ class UpperLevelConstraints final : public NLP_Constraints { public: /** * Default constructor. */ UpperLevelConstraints() = default; /** * Default destructor. */ ~UpperLevelConstraints() override = default; /** * Sets the initial time, and final time. * * @param [in] initTime: The initial time. * @param [in] finalTime: The final time. */ void set(const scalar_t& initTime, const scalar_t& finalTime) { initTime_ = initTime; finalTime_ = finalTime; } void setCurrentParameter(const dynamic_vector_t& x) override { eventTime_ = x; linearInequalityCoefficients(x.size(), initTime_, finalTime_, Cm_, Dv_); } void getLinearInequalityConstraint(dynamic_vector_t& h) override { h = Cm_ * eventTime_ + Dv_; } void getLinearInequalityConstraintDerivative(dynamic_matrix_t& dhdx) override { dhdx = Cm_; } /** * Computes the inequality constraints coefficients for the following conditions: * * \f$t_0 < s_0 < s_1 < ... < s_{n-1} < t_f\f$, * * where \f$t_0\f$ is the initial time and \f$t_f\f$ is the final time. * \f$n\f$ is the number of event times and \f$s_i\f$ is the ith event time. * The inequality constraints have the following format: \f$C_m [s_i] + D_v > 0\f$. * * @param [in] numEventTimes: The number of event times, \f$n\f$. * @param [in] initTime: The initial time, \f$t_0\f$. * @param [in] finalTime: The final time, \f$t_f\f$. * @param [out] Cm: \f$C_m\f$ matrix of the inequality constraints. * @param [out] Dv: \f$D_v\f$ vector of the inequality constraints. * */ static void linearInequalityCoefficients(size_t numEventTimes, scalar_t initTime, scalar_t finalTime, dynamic_matrix_t& Cm, dynamic_vector_t& Dv) { Cm = dynamic_matrix_t::Zero(numEventTimes + 1, numEventTimes); for (size_t i = 0; i < numEventTimes + 1; i++) { if (i < numEventTimes) { Cm(i, i) = +1.0; } if (i > 0) { Cm(i, i - 1) = -1.0; } } Dv = dynamic_vector_t::Zero(numEventTimes + 1); Dv(0) = -initTime; Dv(numEventTimes) = finalTime; } private: scalar_t initTime_; scalar_t finalTime_; dynamic_vector_t eventTime_; dynamic_matrix_t Cm_; dynamic_vector_t Dv_; }; } // namespace ocs2
[ "farbod.farshidian@gmail.com" ]
farbod.farshidian@gmail.com
8c5f5721354939902418c730c63d03a15a20af5e
7bf9f6a72e0af4cf53b8a644a0104f19250fae8e
/core_test/inifile_test.cpp
4f36729581771f5fb12809f4a08b72be72c789e7
[]
no_license
dylancarlson/wwiv
2fcbbad872bd8f9f071f8fd1e004afc0c00efba7
981f86ef636fe6ec36848719de1fd58cf611f364
refs/heads/master
2021-01-25T05:34:22.011234
2014-07-28T05:56:07
2014-07-28T05:56:07
22,399,478
1
2
null
null
null
null
UTF-8
C++
false
false
5,620
cpp
/**************************************************************************/ /* */ /* WWIV Version 5.0x */ /* Copyright (C) 2014, WWIV Software Services */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ /* you may not use this file except in compliance with the License. */ /* You may obtain a copy of the License at */ /* */ /* http://www.apache.org/licenses/LICENSE-2.0 */ /* */ /* Unless required by applicable law or agreed to in writing, */ /* software distributed under the License is distributed on an */ /* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, */ /* either express or implied. See the License for the specific */ /* language governing permissions and limitations under the License. */ /* */ /**************************************************************************/ #include "gtest/gtest.h" #include <cstdio> #include <string> #include <vector> #include "file_helper.h" #include "core/inifile.h" #include "core/strings.h" using std::string; using std::vector; using wwiv::core::IniFile; using wwiv::core::FilePath; class IniFileTest : public ::testing::Test { protected: virtual void SetUp() { const ::testing::TestInfo* const test_info = ::testing::UnitTest::GetInstance()->current_test_info(); test_name_ = test_info->name(); } const string& test_name() const { return test_name_; } string CreateIniFile(const string section, const vector<string> lines) { string path; FILE* file = helper_.OpenTempFile(test_name_, &path); fprintf(file, "[%s]\n", section.c_str()); for (const auto& line : lines) { fprintf(file, "%s\n", line.c_str()); } fclose(file); return path; } string CreateIniFile(const string section1, const vector<string> lines1, const string section2, const vector<string> lines2) { string path; FILE* file = helper_.OpenTempFile(test_name_, &path); fprintf(file, "[%s]\n", section1.c_str()); for (const auto& line : lines1) { fprintf(file, "%s\n", line.c_str()); } fprintf(file, "[%s]\n", section2.c_str()); for (const auto& line : lines2) { fprintf(file, "%s\n", line.c_str()); } fclose(file); return path; } FileHelper helper_; string test_name_; }; TEST_F(IniFileTest, Single_GetValue) { const string path = this->CreateIniFile("TEST", { "FOO=BAR" } ); IniFile ini(FilePath(helper_.TempDir(), this->test_name()), "TEST"); ASSERT_TRUE(ini.IsOpen()); EXPECT_STREQ("BAR", ini.GetValue("FOO")); ini.Close(); } TEST_F(IniFileTest, Single_GetValue_Comment) { const string path = this->CreateIniFile("TEST", { "FOO=BAR ; BAZ" } ); IniFile ini(FilePath(helper_.TempDir(), this->test_name()), "TEST"); ASSERT_TRUE(ini.IsOpen()); EXPECT_STREQ("BAR", ini.GetValue("FOO")); ini.Close(); } TEST_F(IniFileTest, Single_GetNumericValue) { const string path = this->CreateIniFile("TEST", { "FOO=1234", "BAR=4321", "baz=12345" } ); IniFile ini(FilePath(helper_.TempDir(), this->test_name()), "TEST"); ASSERT_TRUE(ini.IsOpen()); EXPECT_EQ(1234, ini.GetNumericValue("FOO")); EXPECT_EQ(4321, ini.GetNumericValue("BAR")); EXPECT_EQ(12345, ini.GetNumericValue("baz")); ini.Close(); } TEST_F(IniFileTest, Single_GetBooleanValue) { const string path = this->CreateIniFile("TEST", { "T1=TRUE", "T2=1", "T3=Y", "F1=FALSE", "F2=0", "F3=N", "U=WTF" } ); IniFile ini(FilePath(helper_.TempDir(), this->test_name()), "TEST"); ASSERT_TRUE(ini.IsOpen()); EXPECT_TRUE(ini.GetBooleanValue("T1")); EXPECT_TRUE(ini.GetBooleanValue("T2")); EXPECT_TRUE(ini.GetBooleanValue("T3")); EXPECT_FALSE(ini.GetBooleanValue("F1")); EXPECT_FALSE(ini.GetBooleanValue("F2")); EXPECT_FALSE(ini.GetBooleanValue("F3")); EXPECT_FALSE(ini.GetBooleanValue("U")); ini.Close(); } TEST_F(IniFileTest, Reopen_GetValue) { const string path = this->CreateIniFile("TEST", { "FOO=BAR" }, "TEST2", { "BAR=BAZ" } ); { IniFile ini(path, "TEST"); ASSERT_TRUE(ini.IsOpen()); EXPECT_STREQ("BAR", ini.GetValue("FOO")); ini.Close(); } IniFile ini(path, "TEST2"); EXPECT_STREQ("BAZ", ini.GetValue("BAR")); ini.Close(); } TEST_F(IniFileTest, TwoSection_GetValue) { const string path = this->CreateIniFile("TEST", { "FOO=BAR" }, "TEST-1", { "FOO=BAZ" } ); IniFile ini(FilePath(helper_.TempDir(), this->test_name()), "TEST-1", "TEST"); ASSERT_TRUE(ini.IsOpen()); EXPECT_STREQ("BAZ", ini.GetValue("FOO")); ini.Close(); } TEST_F(IniFileTest, TwoSection_GetValue_OnlyInSecondary) { const string path = this->CreateIniFile("TEST", { "FOO=BAR" }, "TEST-1", { "FOO1=BAZ" } ); IniFile ini(FilePath(helper_.TempDir(), this->test_name()), "TEST-1", "TEST"); ASSERT_TRUE(ini.IsOpen()); EXPECT_STREQ("BAR", ini.GetValue("FOO")); ini.Close(); } TEST_F(IniFileTest, CommentAtStart) { const string path = this->CreateIniFile("TEST", { ";FOO=BAR" } ); IniFile ini(FilePath(helper_.TempDir(), this->test_name()), "TEST-1", "TEST"); ASSERT_TRUE(ini.IsOpen()); EXPECT_EQ(nullptr, ini.GetValue("FOO")); ini.Close(); }
[ "rushfan@efe8ed7e-8846-41e4-9041-cb610019eb92" ]
rushfan@efe8ed7e-8846-41e4-9041-cb610019eb92
cb166f32d3980dfb65a35619d01aa07c1970d6e9
8faeab92fe4cc5f7bf177776154fe4dd246389aa
/repetition-structure/exer 04/exer 04.cpp
b06f64b01a888736b5ce4b59233924fee23725b3
[]
no_license
LuannMateus/c-exercises
1bea73f3ca969a30c3cb6264082a08b81dede9dd
6d0ea36395019f8c658f1335a54f28e459396607
refs/heads/master
2022-11-13T13:40:52.166974
2020-07-01T19:34:01
2020-07-01T19:34:01
273,738,677
0
0
null
null
null
null
UTF-8
C++
false
false
345
cpp
#include <iostream> #include <stdlib.h> // 4 using namespace std; int main(){ int num, c, soma; cout << "Digite um número que voce queira multiplicar: "; cin >> num; soma = 0; for (c = 1 ; c <= 10; c++){ soma = num * c; cout << num << " * " << c << " = " << soma << "\n"; } return 0; }
[ "luanmateuslima34@gmail.com" ]
luanmateuslima34@gmail.com
d8ea4b56190270244b31f8b991c5d719f2b9e510
aa7eca0eeccc7c71678a90fc04c02dce9f47ec46
/Codes_13TeV/LimitTool_HiggsCombine/ExcitedQuarks/RootTreeAnalyzer/scripts/SoverB.cc
987e7163d9d11b3b91ebcb9c5a2102398d21c3a3
[]
no_license
rockybala/Analyses_codes
86c055ebe45b8ec96ed7bcddc5dd9c559d643523
cc727a3414bef37d2e2110b66a4cbab8ba2bacf2
refs/heads/master
2021-09-15T10:25:33.040778
2018-05-30T11:50:42
2018-05-30T11:50:42
133,632,693
0
2
null
null
null
null
UTF-8
C++
false
false
3,508
cc
#include "TCanvas.h" #include "TDirectory.h" #include "TF1.h" #include "TFile.h" //#include "TFitResult.h" #include "TGraph.h" #include "TGraphErrors.h" #include "TGraphAsymmErrors.h" #include "TH1D.h" #include "TH2D.h" #include "THStack.h" #include "TLegend.h" //#include "TMinuit.h" #include "TMath.h" #include "TProfile.h" #include "TPaveStats.h" #include "TPaveText.h" #include "TROOT.h" #include "TString.h" #include "TStyle.h" #include <iostream> #include <iomanip> #include <vector> #include <string> #include <sstream> using namespace std; using namespace ROOT; void Qstar_SoverB(){ TString InPath80 = "/eos/uscms/store/user/rocky86/13TeV/PA_Results_2015+2016/80X/Optimization/"; TString Opti1 = "JetId_Opti/"; //"DEta_Opti/", "DPhi_Opti/", "JetId_Opti/", "PhId_Opti/" //TString Opti2[8] = {"DEta_1.0", "DEta_1.2", "DEta_1.5", "DEta_1.8", "DEta_2.0", "DEta_2.2", "DEta_2.5", "NoDEta"}; //TString Opti2[4] = {"DPhi_1.5", "DPhi_2.0", "DPhi_2.5", "NoDPhi"}; //TString Opti2[3] = {"PhId_Loose", "PhId_Medium", "PhId_Tight"}; TString Opti2[2] = {"JetId_Tight", "JetId_TightLepVeto"}; for(Int_t i = 0; i < 2; i++){ TFile *f_Total = new TFile(InPath80+Opti1+Opti2[i]+"/MC/Total_BkgMC/Total_BkgMC.root", "READ"); TH1F *h_Total = (TH1F*)f_Total->Get("h_CutFlowWt_qstar"); TFile *fsig = new TFile(InPath80+Opti1+Opti2[i]+"/MC/Signal_Qstar/QstarToGJ_M-3000_f1p0.root", "READ"); TH1F *hsig = (TH1F*)fsig->Get("h_CutFlowWt_qstar"); cout << "---------------------------------------------------------------------------------------" << endl; Double_t binValue_Total, binValue_sig; std::string binName = h_Total->GetXaxis()->GetBinLabel(11); binValue_Total = h_Total->GetBinContent(11); binValue_sig = hsig->GetBinContent(11); Double_t sb = binValue_sig/sqrt(binValue_Total); cout << "| For " << Opti2[i] << " | " << binName << " | Total = " << binValue_Total << " | sig = " << binValue_sig << " | s/sqrt(b) = " << sb << " | "<< endl; cout << "" << endl; } cout << "---------------------------------------------------------------------------------------" << endl; } void Bstar_SoverB(){ TString InPath80 = "/eos/uscms/store/user/rocky86/13TeV/PA_Results_2015+2016/80X/Optimization/"; TString Opti1 = "CSVDisc_Opti/"; TString Opti2[3] = {"CSVL", "CSVM", "CSVT"}; for(Int_t i = 0; i < 3; i++){ TFile *f_Total = new TFile(InPath80+Opti1+Opti2[i]+"/MC/Total_BkgMC/Total_BkgMC.root", "READ"); TH1F *h_Total = (TH1F*)f_Total->Get("h_CutFlowTotalWt_bstar"); TFile *fsig = new TFile(InPath80+Opti1+Opti2[i]+"/MC/Signal_Bstar/BstarToGJ_M-2000_f1p0.root", "READ"); TH1F *hsig = (TH1F*)fsig->Get("h_CutFlowTotalWt_bstar"); cout << "---------------------------------------------------------------------------------------" << endl; Double_t binValue_Total, binValue_sig; std::string binName = h_Total->GetXaxis()->GetBinLabel(12); binValue_Total = h_Total->GetBinContent(12); binValue_sig = hsig->GetBinContent(12); Double_t sb = binValue_sig/sqrt(binValue_Total); cout << "| For " << Opti2[i] << " | " << binName << " | Total = " << binValue_Total << " | sig = " << binValue_sig << " | s/sqrt(b) = " << sb << " | "<< endl; cout << "" << endl; } cout << "---------------------------------------------------------------------------------------" << endl; }
[ "rgarg@cern.ch" ]
rgarg@cern.ch
ee97a55adc71db766e4a7c3b41c0b0cfc0840236
05f7573db159e870fb26c847991c4cb8c407ed4c
/VBF/Source/VBF_CORE4.0/VBF_Public/VBF_Engine/VBF_SceneGraph/VBFO_StateAttrLogicOp.h
522592d4badf5898259702820eee992434c718ca
[]
no_license
riyue625/OneGIS.ModelingTool
e126ef43429ce58d22c65832d96dbd113eacbf85
daf3dc91584df7ecfed6a51130ecdf6671614ac4
refs/heads/master
2020-05-28T12:12:43.543730
2018-09-06T07:42:00
2018-09-06T07:42:00
null
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
3,691
h
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield * * This library is open source and may be redistributed and/or modified under * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or * (at your option) any later version. The full license is in LICENSE file * included with this distribution, and on the openscenegraph.org website. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * OpenSceneGraph Public License for more details. */ #ifndef OSG_LOGICOP #define OSG_LOGICOP 1 #include <VBF_Engine/VBF_SceneGraph/VBFO_StateAttribute.h> #ifndef OSG_GL_FIXED_FUNCTION_AVAILABLE #define GL_CLEAR 0x1500 #define GL_SET 0x150F #define GL_COPY 0x1503 #define GL_COPY_INVERTED 0x150C #define GL_NOOP 0x1505 #define GL_AND 0x1501 #define GL_NAND 0x150E #define GL_OR 0x1507 #define GL_NOR 0x1508 #define GL_XOR 0x1506 #define GL_EQUIV 0x1509 #define GL_AND_REVERSE 0x1502 #define GL_AND_INVERTED 0x1504 #define GL_OR_REVERSE 0x150B #define GL_OR_INVERTED 0x150D #define GL_COLOR_LOGIC_OP 0x0BF2 #endif namespace osg { /** Encapsulates OpenGL LogicOp state. */ class OSG_EXPORT LogicOp : public StateAttribute { public : enum Opcode { CLEAR = GL_CLEAR, SET = GL_SET, COPY = GL_COPY, COPY_INVERTED = GL_COPY_INVERTED, NOOP = GL_NOOP, INVERT = GL_INVERT, AND = GL_AND, NAND = GL_NAND, OR = GL_OR, NOR = GL_NOR, XOR = GL_XOR, EQUIV = GL_EQUIV, AND_REVERSE = GL_AND_REVERSE, AND_INVERTED = GL_AND_INVERTED, OR_REVERSE = GL_OR_REVERSE, OR_INVERTED = GL_OR_INVERTED }; LogicOp(); LogicOp(Opcode opcode); // IE¿ÉÄÜ´íÎó /** Copy constructor using CopyOp to manage deep vs shallow copy. */ LogicOp(const LogicOp& trans,const CopyOp& copyop=CopyOp::SHALLOW_COPY): StateAttribute(trans,copyop), _opcode(trans._opcode){} META_StateAttribute(osg, LogicOp,LOGICOP); /** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */ virtual int compare(const StateAttribute& sa) const { // Check for equal types, then create the rhs variable // used by the COMPARE_StateAttribute_Parameter macros below. COMPARE_StateAttribute_Types(LogicOp,sa) // Compare each parameter in turn against the rhs. COMPARE_StateAttribute_Parameter(_opcode) return 0; // Passed all the above comparison macros, so must be equal. } virtual bool getModeUsage(StateAttribute::ModeUsage& usage) const { usage.usesMode(GL_COLOR_LOGIC_OP); return true; } inline void setOpcode(Opcode opcode) { _opcode = opcode; } inline Opcode getOpcode() const { return _opcode; } virtual void apply(State& state) const; protected : virtual ~LogicOp(); Opcode _opcode; }; } #endif
[ "robertsam@126.com" ]
robertsam@126.com
9f6c4057caf0d969f61fddcd6a386ba8f2126ea9
a071d07770b2bc654fec15d916df5966c19ec377
/src/io/model_importers/CompositeFileImporter.cpp
8a86a988ed2c7eef7067abb4823190e8e9bf311a
[]
no_license
joshi1983/UAVSim
8381ab53713a17e63fdb7b9222dfd3e0ce2a396c
6ca74fb85158c2ef8b342cca38720a370fefb2e7
refs/heads/master
2023-07-06T04:58:16.386970
2021-08-06T19:16:19
2021-08-13T03:36:42
359,058,663
0
0
null
null
null
null
UTF-8
C++
false
false
1,515
cpp
#include "CompositeFileImporter.hpp" #include "OBJFileImporter.hpp" #include "OFFFileImporter.hpp" #include "OSMFileImporter.hpp" #include "PLYFileImporter.hpp" #include "STLFileImporter.hpp" #include "TRIFileImporter.hpp" #include "UAVSimBinaryFileImporter.hpp" #include "WRLFileImporter.hpp" #include "X3DFileImporter.hpp" using namespace std; CompositeFileImporter::CompositeFileImporter(): FileImporter("") { importers.push_back(new OBJFileImporter()); importers.push_back(new OFFFileImporter()); importers.push_back(new OSMFileImporter()); importers.push_back(new PLYFileImporter()); importers.push_back(new STLFileImporter()); importers.push_back(new TRIFileImporter()); importers.push_back(new UAVSimBinaryFileImporter()); importers.push_back(new WRLFileImporter()); importers.push_back(new X3DFileImporter()); } CompositeFileImporter::~CompositeFileImporter() { for (auto im = importers.begin(); im != importers.end(); im++) delete *im; } bool CompositeFileImporter::supportsFileExtension(const string & filename) const { for (auto importer = importers.begin(); importer != importers.end(); importer++) { if ((*importer)->supportsFileExtension(filename)) return true; } return false; } GroupNode* CompositeFileImporter::load(const string & filename) const { for (auto importer = importers.begin(); importer != importers.end(); importer++) { if ((*importer)->supportsFileExtension(filename)) return (*importer)->load(filename); } return NULL; // unable to load. }
[ "josh.greig@gmail.com" ]
josh.greig@gmail.com
f72fcf0217ae56413ecc84eb27826d1d38d57b62
8d3f7af580e9c2c335bf8ca01954521258af730a
/Codechef Dec 2020/VACCINE2.cpp
fce41bbf3fb0295f5f131af209a3a012c1f61973
[]
no_license
mr-kotresh-gb/Codechef-Long-Challenges
632b3d918b681cdb79c0a5d7163eeac9da0bcc0e
17ea1252b94ded3626e35055868edcfb27086991
refs/heads/main
2023-02-09T11:56:04.051898
2021-01-04T03:12:45
2021-01-04T03:12:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
601
cpp
/* Question link -> https://www.codechef.com/DEC20B/problems/VACCINE2 Code By -> Kotresh G B Date -> 04/12/2020 */ #include<bits/stdc++.h> using namespace std; #define ll long long int int main() { ll t; cin >> t; while(t--) { ll n, d; cin >> n >> d; ll a[n], risk = 0, norisk = 0; for(int i = 0; i < n; i++) { cin >> a[i]; if(a[i] >= 80 || a[i] <= 9) risk++; else norisk++; } ll sum = ceil((double) risk / (double)d) + ceil((double)norisk / (double)d); cout << sum << "\n"; } }
[ "noreply@github.com" ]
noreply@github.com