Reference request: clean intersection between sub-varieties

Let $ N_1, N_2 $ to be two smooth submanifolds in an ambient variety $ M $.
There are two definitions of own intersection enter $ N_1 $ and $ N_2 $:

  • $ N_1 $ and $ N_2 $ intersect neatly if $ N_1 cap N_2 $ is a smooth subtype such as $ T_x (N_1 cap N_2) = T_xN_1 cap T_xN_2 $ for each $ x in N_1 cap N_2 $.
  • There are about every $ x in N_1 cap N_2 $ a map $ (U, phi) $ such as $ phi (N_1 cap U) $ and $ phi (N_2 cap U) $ are open subsets of affine subspaces $ V_1, V_2 subset mathbb {K} ^ d $.

Without a doubt, using the implicit function theorem, you can produce an elegant (or less elegant) proof that the two definitions are equivalent. But if possible, I would like to have a reference (to a standard manual?). Do you know?

cannon – Speck on the photos – do not know how to clean

I bought a Canon eos 6d about 10 months ago and all my photos have a spot on them in the center of each photo. I peeked at a picture that the seller had shown that he had taken with it before buying the camera. She was also in her picture, but I never noticed her zooming in that way.

Anyway, one thing I noticed is that the grain is NOT there when I make a video with the camera.

I tried cleaning the sensor with amazon cleaning tapes and that did not help. I just do not understand how the grain can be there. It's there, no matter what lens I use, but again, not on the videos (recorded with a bright background to see it).

18.04 – Start stuck on / dev / nvme0n1p2: clean ?? HELP ME!

I am a new user of Ubuntu and it is my last resort to try to repair my computer. I hope someone can help me out.

I have a Dell Inspiron 15 5000, Intel Core i3-1080p. It's all new and it came with Windows, but I've since installed Ubuntu and used it well for over a month. Everything worked well, the installation went perfectly well.

I wanted to change the default purple login screen for a different image or color, so I looked for it if you could do it. You could do it, but it had to be through the terminal. Here is the tutorial I followed to change it: https://vitux.com/how-to-change-login-lock-screen-background-in-ubuntu/

I followed the instructions precisely and everything looked exactly as they said, but I had to restart it for everything to take effect. It made sense, but when I restarted it, the desktop blinked once and now I'm stuck with a black screen that says "/ dev / nvme0n1p2: clean" and so on. user manager for the UID 121 "and" the session started c1 of the user gdm ". (I've tried to add a photo to this ticket but it's not the same. was apparently too big.)

The screen on which it is blocked normally appears when I start the computer, then it will go to the desktop and work properly, but it just stays there. I can not do anything with that. I've tried things like go through the GRUB menu, check the boot menu, and nothing works. I did so many different things that I lost count. I called people, nobody supports Ubuntu / Linux. I am completely stuck. PLEASE HELP! I am new to this field and I leave for university tomorrow and here is my computer that I was going to use. I'm in desperate need of a solution.

Clean infected WordPress sites

I have forgotten any plugin: none of them works at 100%.

And you can not clean up a site that is online.

You must copy it to a local environment, clean it, delete everything from the current hosting and download the own content again.

Look for someone competent, otherwise you may lose weeks for this type of task.

Homemakers and their duty to clean everything – Cleaning the air ducts Dr – Everything Else

The essence of having a clean and good home for your family

There are many good things to do when you live in a good home. First of all, you will have a positive vision of life. You will have less worries and less stress to think. Second, you and your family will live a healthy life. The disease will be reduced and your diet will be consciously Finally, because of all the things mentioned above, you will have a good and happy family to live with.

Related image

· To fix everything, you must be meticulous with the things inside your home. You must ensure that everything is dust free to maintain order and extend the life of your devices and tools.

· You have to prepare healthy, healthy meals for your family every day, three times a day. Make sure to prepare healthy meals, like vegetables, both delicious and delicious. Make sure there are fruits available all the time in your refrigerator and the kitchen counter.

Cleaning the air ducts: a priority for you and your family

A clean house makes sense and gives a strong point to all. That's why there are good materials on the market to help you maintain a clean home for your family. the Cleaning the air ducts material is a good example for a very useful cleaning material. This will help you clean your air ducts for good ventilation throughout the year.

Related image

This material is available at stores near you and can also be purchased at online stores. You can simply have it delivered to your door for convenience and less hassle. It will be very effective for you and your family. A good family starts with a clean house.

laravel – Splits / splits a .php file into several clean parts

I wrote a page with Laravel to manage projects with Scrumpoker thanks to the syntax of the blade with controllers, models and View js.

My problem is that I wrote the Scrumpoker in a single file.php file and that it loads using a method via an onclick event of a form.

Now, I want to split it, refactoring it and implement it in my own .php laravel files. I do it because it does not recover all the images from my folder / storage properly and does not create a clean project.

Thanks in advance, my help as needed receives a small reward for helping me out of this messy structure.

Here is the code (only the file index.php + the images folder with / themes / decksize / 13plus1 or / themes / decksize / 6plus1 with a file a.png / b.png / std.png cut into a single image)


    board (
"1" => "(0)",
"2" => "(1/2)",
"3" => "(1)",
"4" => "(2)",
"5" => "(3)",
"6" => "(5)",
"7" => "(8)",
"8" => "(13)",
"9" => "(20)",
"10" => "(40)",
"11" => "(100)",
"12" => "(?)",
"13" => "(C)",
// 14 => back of the card
)
& # 39; 6plus1 & # 39; => array (
"1" => "(1) piece of cake",
"2" => "(3) Hexenwerk",
"3" => "(8) Raketenwissenschaft",
"4" => "(100) O M G!",
"5" => "(?) Ich brauche mehr details",
"6" => "(C) Kaffeepause",
// 7 => back of the card
)
)

// will be used to split the theme.png image into x slices - one per card
define (#CARDS_IN_THEME, sizeof ($ validOptions ($ _SESSION ('package size')))) + 1);


dbg function ($ str)
{
if (DEBUG) {
echo $ str;
}
}

// define a standard theme if no theme is defined
if (! isset ($ _GET (& # 39;))))) {
$ _GET ('theme') = 'A';
}

// player name is the name of the file? == admin
$ admin = false;
if (isset ($ _GET (& # 39;)) && isset ($ _GET (& # 39; table)) && $ _GET (& # 39;) == $ _GET (& # 39; table)
$ admin = true;
}

// calculate the width and height of the map and check if the theme is available on the disk
$ offsets = getCardOffset ("1", $ validOptions ($ _SESSION (& # 39; decksize & # 39;)), $ _GET (& # 39; theme);
if (is_array ($ offsets)) {
$ cardWidth = $ offsets (1);
$ placeWidth = 20 + $ offsets (1);
$ cardHeight = $ offsets (2);
$ placeHeight = 20 + $ offsets (2);
} other {
$ cardWidth = 50;
$ placeWidth = 100;
$ cardHeight = 75;
$ placeHeight = 95;
}


// Processing AJAX requests
// new players come here, their ajax cards or commands to reset the table
if (isset ($ _GET (& # 39; table)) && isset ($ _GET (& # 39; ajax & # 39;))) {
// tabledata is stored in a file with the same name as table in / tmp
// for security - prevents writing to directories other than / tmp by removing all dots and slashes
$ table = str_replace (array (& # 39 ;, & # 39;); & # 39;; & gt; $ _GET (& # 39; table)) ;

// create a new game if the player is admin and no game exists
if (! file_exists (PATH_TO_DATA_FILE. $ table) && $ admin) {
touch (PATH_TO_DATA_FILE. $ table);
}

// stop all players from playing on non-existent tables
// ajax queries to non-existing tables stop here
if (! file_exists (PATH_TO_DATA_FILE. $ table)) {
echo # The table does not exist. & # 39;;
exit;
}

// making sure that ONE player fiddles at the same time the matrix on the disc
while (! @mkdir (LOCKFILE)) {
sleep (2);
}

// read the tabledata of the file
$ filedata = unserialize (file_get_contents (PATH_TO_DATA_FILE. $ table));
if (! is_array ($ filedata)) {
$ filedata = array ();
}

// kill the game if asked
if (isset ($ _GET (& # 39; kill)) && $ admin) {
$ filedata = array ();
unlink (PATH_TO_DATA_FILE. $ table);
echo "killed table";
rmdir (LOCKFILE);
exit;
}

// initiate a new game when it's not over yet
if (! isset ($ filedata (& # 39; table)))) {
$ filedata (& # 39; table) = array ();
}
if (! isset ($ filedata (& # 39;))))) {
$ filedata (& # 39; history & # 39;) = array ();
}
if (! isset ($ filedata (& # 39;))))) {
$ filedata ('message') = 'Welcome to Scrummy: & # 39 ;;
}

// divide the game board into subparts
$ tabledata = $ filedata (& # 39; table); // table of the current game (on the red cover)
$ tabledatahistory = $ filedata (& # 39; history); // table containing the previous tables (under the red cover)
$ players = $ filedata (& # 39; players & # 39;); // table containing the latest timestamps for players
$ message = $ filedata (& # 39; message); // message from the table


if (isset ($ _GET (& # 39; options) && $ _GET (& # 39; options)) {
// substitution message for the table
if (strpos ($ _GET (& # 39; options), & # 39; https: //it.ly/2NDNWF8')! == false) {
$ _GET (& # 39; options & # 39;)
=
& # 39;& # 39 ;. str_replace (
"Https://it.ly/2NDNWF8"
& # 39; & # 39 ;,
$ _GET (& # 39; options & # 39;)
). & # 39;& # 39 ;;
}
$ filedata ('message') = $ _GET ('options');
$ message = $ filedata (& # 39; message);
file_put_contents (PATH_TO_DATA_FILE. $ table, serialize ($ filedata));
}

// check the handling of the user
$ userIsSpoofingArround = false;
if (isset ($ _GET (& # 39;)) && isset ($ _GET (& # 39;)) && $ tabledata ($ _GET (& # 39; name)) (& # 39;) &! = $ _GET (& # 39; ID & # 39;)) {
$ userIsSpoofingArround = true;
}

if (isset ($ _GET (& # 39;)) && isset ($ tabledata ($ _GET (& # 39;))) && $ userIsSpoofingArround) {
if ((time () - $ players ($ _GET (& # 39;))))) <IDLE_TIMEOUT_DELETE_SECONDS) {
dbg ("(". $ tabledata ($ _GET ("name")) ("ID") ") == (". $ _GET (& # 39; ID & # 39; ;). ")
"); echo # AUTHENTICATION PROBLEM - FRAUD DETECTED! & # 39 ;; rmdir (LOCKFILE); exit; } other { // the user usurps another user who has stopped. the user can take the session if ($ _GET (& # 39; ID & # 39;)) { $ tabledata ($ _GET (& # 39;)) (& quot; ID & quot;) = $ _GET (& # 39; ID & # 39;); dbg ("Update ID
"); } } } other { // echo "(". $ tabledata ($ _GET (& # 39;)) (& quot; ID & # 39;).) == (". $ _GET (& # 39; ID & # 39;). ")
"; } // put the current game in the history if (isset ($ _GET (& # 39; add & # 39;)) && $ admin) { $ tabledatahistory () = $ tabledata; $ tabledata = array (); $ filedata (& # 39; table) = $ tabledata; $ filedata (& # 39; history & # 39;) = $ tabledatahistory; file_put_contents (PATH_TO_DATA_FILE. $ table, serialize ($ filedata)); rmdir (LOCKFILE); exit; } // define a card for a player if all _GET data is valid if ( isset ($ _GET (& suppose & # 39;)) && $ _GET (& # 39; suppose & # 39;)! = & # 39; && isset ($ _GET (& # 39;)) && $ _GET (& # 39;) && isset ($ tabledata ($ _GET (& # 39; name))) && $ tabledata ($ _GET (& # 39;)) (& # 39; ID & # 39;) == $ _GET (& # 39; ID & # 39;) ) { if (in_array ($ _GET ("suppose"), array_keys ($ validOptions ($ _SESSION ("platform size")))))) { dbg ("saving time to guess and update
"); $ tabledata ($ _GET (& # 39;)) = array (& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; => $ _GET ('suppose'), 'ID' => $ _GET ('ID')); $ players ($ _GET (& # 39;)) = time (); } } // recognize the new player without a card - prepare the slot if (isset ($ _GET (& # 39;)) &&! isset ($ tabledata ($ _GET (& # 39;)) && isset ($ _GET (& # 39; name & # 39; 39;)) && $ _GET (& # 39;))) { $ tabledata ($ _GET (& # 39;)) = array (& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; => & # 39 ;, & quot; ID & # 39; => $ _GET (& # 39; ID & # 39;)) dbg ("adding a new player with diviner ...
"); } // remove inactive players after IDLE_TIMEOUT_SECONDS if (isset ($ _GET (& # 39;)) && isset ($ tabledata ($ _GET (& # 39;)) && $ _GET (& # 39;) &&! $ userIsSpoofingArround) { $ players ($ _GET (& # 39;)) = time (); dbg ("update time
"); } // combine the story and the current game in a table $ filedata (& # 39; table) = $ tabledata; $ filedata (& # 39; history & # 39;) = $ tabledatahistory; $ filedata (& # 39; players & # 39;) = $ players; $ filedata (& # 39;) & # 39;) = $ message; // write the data from the table to the disk if (isset ($ _GET (& # 39;)) && $ _GET (& # 39;)) { file_put_contents (PATH_TO_DATA_FILE. $ table, serialize ($ filedata)); dbg ("writing data to disk
"); } // prepare the layout of the web page // show all cards $ showAllCards = true; // echo table header with names ksort ($ players); $ playernames = array (); if (is_array ($ players)) { $ playernames = array_keys ($ players); } $ totalPlayers = 0; $ activePlayers = 0; $ playersOnTable = 0; // check if some players have not yet chosen if (is_array ($ playernames)) { foreach ($ playernames as $ eachPlayername) { $ totalPlayers ++; if ((time () - $ players ($ eachPlayername)) <IDLE_TIMEOUT_SECONDS) { $ activePlayers ++; } if ((time () - $ players ($ eachPlayername)) <IDLE_TIMEOUT_DELETE_SECONDS) { $ playersOnTable ++; } if ( $ tabledata ($ eachPlayername) ("suppose") == & # 39; ... & # 39; && (time () - $ players ($ eachPlayername)) < IDLE_TIMEOUT_SECONDS ) { $showAllCards = false; } } } // automatic new row if ($showAllCards && $activePlayers > 1) { $ tabledatahistory () = $ tabledata; // $ tabledata = array (); <-- will not work - enables session hijacking foreach ($tabledata as $username => $ userarray) { $ tabledata ($ username) ("suppose") = "#"; } $ filedata (& # 39; table) = $ tabledata; $ filedata (& # 39; history & # 39;) = $ tabledatahistory; file_put_contents (PATH_TO_DATA_FILE. $ table, serialize ($ filedata)); } rmdir (LOCKFILE); echo & # 39;Take a break (STOP REFRESH)

& # 39 ;; echo & # 39;

& # 39 ;. $ message. & # 39;

& # 39 ;; echo & # 39;
Players on the table: & # 39; $ playersOnTable. "
"; echo & # 39; Total Player: & # 39; $ totalPlayers. "
"; echo & # 39; Active players: & # 39; $ activePlayers. "
"; echo & # 39;
& # 39 ;; if (is_array ($ playernames)) { foreach ($ playernames as $ eachPlayerName) { $ id = (& # 39 ;. $ tabledata ($ eachPlayerName) (& # 39;) & # 39;) & # 39;. $ _GET (& # 39; ID & # 39; ;); & # 39;) & # 39 ;; $ id = & # 39; if (time () - $ players ($ eachPlayerName) <IDLE_TIMEOUT_SECONDS) { echo & # 39;
& # 39 ;. & # 39;& # 39 ;. & # 39; Player & # 39 ;. & # 39;& # 39 ;. & # 39; & # 39; $ eachPlayerName. & # 39;
& # 39; ./*&# 39;& # 39; .hash (& # 39; sha512 & # 39 ;, session_id ($ eachPlayerName)). & # 39;& # 39 ;. * / $ id . & # 39;
& # 39 ;; } elseif (time () - $ players ($ eachPlayerName) <IDLE_TIMEOUT_DELETE_SECONDS) { echo & # 39;
& # 39 ;. $ eachPlayerName. $ id . & # 39;
INACTIVE
& # 39 ;; } } echo & # 39;
& # 39 ;; // CURRENT TABLE echo & # 39;
& # 39 ;; foreach ($ playernames as $ eachPlayerName) { $ styleaddon = & # 39 ;; $ ownPlace = (isset ($ _GET (& # 39; name)) && $ tabledata ($ eachPlayerName) (& # 39;) == $ _GET (& # 39;) ); $ playerPlayedACard = ($ tabledata ($ eachPlayerName) (& gt; guess & # 39;)! = & # 39;); if (time () - $ players ($ eachPlayerName) <IDLE_TIMEOUT_DELETE_SECONDS) { echo & # 39;
& # 39 ;; $ offsets = getCardOffset ($ tabledata ($ eachPlayerName) ('suppose'), $ validOptions ($ _SESSION ('decksize')), $ _GET ('theme' )); if (is_array ($ offsets)) { // show clever cards echo & # 39; & # 39; . (($ showAllCards || ($ ownPlace && $ playerPlayedACard))) ? // show the card face up & # 39;
& nbsp;
& # 39; : ($ playerPlayedACard ? // show the card face down & # 39;
& nbsp;
& # 39; : // show the empty place & # 39;
& nbsp;
& # 39;)). & # 39; & # 39 ;; } other { // theme not found or wrong - displays text cards echo & # 39; & # 39; . (($ showAllCards || ($ ownPlace && $ playerPlayedACard))) ? // show the card face up & # 39;
& # 39; . $ validOptions ($ _SESSION (& # 39; decksize & # 39;))) $ tabledata ($ eachPlayerName) (& gt; guess & # 39;)). & # 39;
& # 39; : ($ playerPlayedACard ? // show the card face down & # 39;& # 39; : // show the empty place & # 39;
& nbsp;
& # 39;)). & # 39; & # 39 ;; // & # 39;& # 39;)); } echo & # 39;
& # 39 ;; } } echo & # 39;
& # 39 ;; $ tabledatahistory = array_reverse ($ tabledatahistory); // THE HISTORY foreach ($ tabledatahistory as $ eachHistory) { echo & # 39;
& # 39 ;; foreach ($ playernames as $ eachPlayerName) { if (time () - $ players ($ eachPlayerName) <IDLE_TIMEOUT_DELETE_SECONDS) { echo & # 39;

& # 39 ;. $ eachPlayerName. & # 39;


& # 39 ;. & # 39;
& # 39 ;; $ offsets = getCardOffset ($ eachHistory ($ eachPlayerName) ('suppose'), $ validOptions ($ _SESSION ('decksize')), $ _GET ('theme' )); if (is_array ($ offsets)) { // show clever cards echo & # 39;
& nbsp;
& # 39 ;; } other { // theme not found or wrong - displays text cards echo & # 39;
& # 39; . $ validOptions ($ _SESSION (& # 39; decksize & # 39;)) ($ eachHistory ($ eachPlayerName) (& gt; assume & # 39;)). & # 39;
& # 39 ;; } echo & # 39;
& # 39 ;; } } echo & # 39;
& # 39 ;; } } // echo & # 39;
& # 39 ;;

exit;
}
$ ID = session_id ();


/ **
* @param $ assumes
* @param $ validOptions
* @param $ theme
* @back string
* /
getCardOffset function ($ assume, $ validOptions, $ theme)
{
$ return = 0;
$ found = false;
$ imageName = & # 39; storage / themes / & # 39; $ _SESSION (& # 39; decksize & # 39;). & # 39; / & # 39; str_replace (array (& # 39 ;, & # 39;), & # 39;, $ theme). & # 39; & # 39 ;; .png

if (file_exists ($ imageName)) {
$ img = imagecreatefrompng ($ imageName);
if ($ img) {
$ width = imagesx ($ img);
$ cardWidth = $ width / CARDS_IN_THEME;
foreach ($ validOptions as $ key => $ val) {
if ($ suppose! = $ key) {
$ return - = $ cardWidth;
} other {
$ found = true;
Pause;
}
}
} other {
returns false;
}
} other {
returns false;
}
if (! $ found) {
returns false;
}
return array ($ return. "px", $ cardWidth, imagesy ($ img), $ imageName. "# filemtime ($ imageName));
}

if (! isset ($ _GET (& # 39;))))) {

$ folder = & # 39; themes / & # 39; $ _SESSION (& # 39; decksize & # 39;). & # 39; / & # 39 ;;
$ otherfolder = 'themes / 6plus1'. $ _SESSION (& # 39; secdecksize & # 39;). & # 39; / & # 39 ;;



exit;
} other {


// manage the HTML page for the client
?>
    

    
        scrummy

        
        
        
        



        
        
    

    
            0; $ i--) {
// echo & # 39;& # 39 ;;
}
// echo & # 39;
& # 39 ;; ?>
<select id = "assume" name = "assume" onchange = "showUser (this.value, & # 39;& # 39; & # 39;& # 39;) "> $ val) { echo " not "; } ?>
$ val) { $ offsets = getCardOffset ($ key, $ validOptions ($ _SESSION (& # 39; decksize & # 39;)), $ _GET (& # 39; theme); echo & # 39;& # 39 ;; } echo & # 39;
& # 39 ;; // echo & # 39;STOP REFRIGERATING& # 39 ;; ?> <entry name = "message" size = "100" onkeypress = "statusCommand (& # 39; message, & # 39;& # 39; & # 39;& # 39 ;, this.value) "onkeyup =" statusCommand (& # 39; message & # 39;, & # 39;& # 39; & # 39;& # 39 ;, this.value) "onchange =" statusCommand (& # 39; message & # 39;, & # 39;& # 39; & # 39;& # 39 ;, this.value) "onblur =" statusCommand (& # 39; message & # 39;, & # 39;& # 39; & # 39;& # 39 ;, this.value) ">

<? php if ($ admin) { echo & # 39;& # 39 ;. "You are the Scrumleader". & # 39;& # 39 ;. & # 39;
& # 39 ;; ?> <A href = "javaScript: statusCommand (& # 39; kill & # 39 ;, & # 39;& # 39; & # 39;& # 39;) "> Reset the current game
<A href = "javaScript: statusCommand (& # 39; add & # 39 ;, & # 39;& # 39; & # 39;& # 39;) "> New Round? (Add a new line of play)
The cards are shown here
`` `

Python 3.x – how to compare data containing values ​​such as 1930-31 and 1980-81, how to clean these data to be able to compare 2

how to compare data containing values ​​such as 1930-31 and 1980-81, how to clean these data in order to compare 2.

import pandas as pd ## important pandas library
import numpy as ny
laliga = pd.read_csv (Laliga.csv & # 39;). set_index (& # 39; Pos & # 39;)
the league

php – Is it necessary to clean the user input wp_set_password?

I'm trying to add a password form to the WP registration form. See the code below. I was wondering if I should erase this specific user entry? (and if yes, how?)

As I understand it, the disinfection of WP is built into some things, and passwords can be part of it. Is it correct? Will WP disinfect it automatically before adding it to the database?

add_action( 'register_new_user', 'registration_change_pass', 10, 99 );

function registration_change_pass( $user_id ) {

    if ( isset( $_POST('user_password') ) ) {
        wp_set_password( $_POST('user_password'), $user_id ); }
}```

object-oriented – Calculation of the first n primes: example of the revised Clean Code for C ++

I'm trying to improve the examples of Own code* by re-implementing them in C ++. This time, it is the sieve of Eratosthenes, an example of computation based on the primordial computer science on pp.

Below, the original adapted for C ++, without improvements:

.h

class PrimeGenerator { 
public:
    PrimeGenerator() = default;
    ~PrimeGenerator() = default;

    static std::vector generatePrimes(unsigned maxValue);

private:
    static void uncrossIntegersUpTo(unsigned maxValue);
    static void crossOutMultiples();
    static unsigned determineIterationLimit();
    static void crossOutMultiplesOf(unsigned i);
    static bool notCrossed(unsigned i);
    static void putUncrossedIntegersIntoResult();
    static unsigned numberOfUncrossedIntegers();

    static std::vector crossedOut;
    static std::vector result; 
};

cpp

std::vector PrimeGenerator::crossedOut;
std::vector PrimeGenerator::result;

std::vector PrimeGenerator::generatePrimes(unsigned maxValue)
{
    if (maxValue < 2)
        return {};

    uncrossIntegersUpTo(maxValue);
    crossOutMultiples();
    putUncrossedIntegersIntoResult();
    return result;
}

void PrimeGenerator::uncrossIntegersUpTo(unsigned maxValue)
{
    crossedOut = std::vector(maxValue + 1, false);
    crossedOut(0) = true;
    crossedOut(1) = true;
}

void PrimeGenerator::crossOutMultiples()
{
    unsigned limit = determineIterationLimit();
    for (size_t i = 2; i <= limit; ++i)
    {
        if (notCrossed(i))
            crossOutMultiplesOf(i);
    }
}

unsigned PrimeGenerator::determineIterationLimit()
{
    // Every multiple in the array has a prime factor that
    // is less than or equal to the root of the array size,
    // so we don't have to cross out multiples of numbers
    // larger than that root.
    double iterationLimit = std::sqrt(crossedOut.size());
    return static_cast(iterationLimit);
}

void PrimeGenerator::crossOutMultiplesOf(unsigned i)
{
    for (size_t multiple = 2 * i; multiple < crossedOut.size(); multiple += i)
    {
        crossedOut(multiple) = true;
    }
}

bool PrimeGenerator::notCrossed(unsigned i)
{
    return !crossedOut(i);
}

void PrimeGenerator::putUncrossedIntegersIntoResult()
{
    result = std::vector(numberOfUncrossedIntegers());
    size_t j = 0;
    for (size_t i = 2; i < crossedOut.size(); ++i)
    {
        if (notCrossed(i))
            result(j++) = i;
    }
}

unsigned PrimeGenerator::numberOfUncrossedIntegers()
{
    unsigned count = 0;
    for (size_t i = 2; i < crossedOut.size(); ++i)
    {
        if (notCrossed(i))
            count++;
    }

    return count;
}

What we see here is a static class with static functions and members. We do not like this in C ++, so it seems that this code could be better served with a namespace and free functions. Let's try - my attempt at improvement comes below.

.h

namespace PrimeGenerator
{
    std::vector generatePrimes(unsigned maxValue);
}

cpp

namespace {

std::vector uncrossIntegersUpTo(int maxValue)
{
    std::vector crossedOut(maxValue + 1, false);
    crossedOut(0) = true;
    crossedOut(1) = true;

    return crossedOut;
}

unsigned determineIterationLimit(size_t size)
{
    // Every multiple in the array has a prime factor that
    // is less than or equal to the root of the array size,
    // so we don't have to cross out multiples of numbers
    // larger than that root.
    double iterationLimit = std::sqrt(size);
    return static_cast(iterationLimit);
}

void crossOutMultiplesOf(unsigned i, std::vector& crossedOut)
{
    for (size_t multiple = 2 * i; multiple < crossedOut.size(); multiple += i)
    {
        crossedOut(multiple) = true;
    }
}

void crossOutMultiples(std::vector& crossedOut)
{
    unsigned limit = determineIterationLimit(crossedOut.size());
    for (size_t i = 2; i <= limit; ++i)
    {
        if (!crossedOut(i))
            crossOutMultiplesOf(i, crossedOut);
    }
}

std::vector putUncrossedIntegersIntoResult(const std::vector& crossedOut)
{
    std::vector result;
    for (size_t i = 2; i < crossedOut.size(); ++i)
    {
        if (!crossedOut(i))
            result.push_back(i);
    }

    return result;
}

}

namespace PrimeGenerator {

std::vector generatePrimes(unsigned maxValue)
{
    if (maxValue < 2)
        return {};

    auto crossedOut = uncrossIntegersUpTo(maxValue);
    crossOutMultiples(crossedOut);
    return putUncrossedIntegersIntoResult(crossedOut);
}

}

A quick summary of the changes:
- I deleted the class, leaving only one interface function in a PrimeGenerator namespace.
- The numberOfUncrossedIntegers() the function did not seem to make much sense, so I refactored putUncrossedIntegersIntoResult(...) get rid of the old.
- notCrossed(...) would now need two parameters, so that makes no sense. It's gone now.

Now, I have two questions about my code. First of all, we must now pass the crossedOut vector around, which is a disadvantage compared to the previous design. Would you suggest an alternative solution to mitigate this? Secondly, are there any additional places where I should have used size_t instead of unsigned?

Cheers!


* Clean Code: An Agile Software Craft ManualRobert C. Martin