Page 1 of 1

BEGINNER C++ STL SET CONTAINER TUTORIAL BEGINNER C++ STL SET CONTAINER TUTORIAL Rate Topic: ****- 1 Votes

#1 Elcric  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 101
  • View blog
  • Posts: 453
  • Joined: 02-May 09

Posted 01 July 2009 - 11:34 AM

BEGINNER C++ STL SET CONTAINER TUTORIAL


CONTENTS
• I. ASSUMPTIONS
• II. INTRODUCTION
• III. VOCABULARY
• IV. DECLARING A SET
• V. DECLARING A SET ITERATOR
• VI. INITIALIZING A SET ITERATOR
• VII. INITIALIZING A SET.
• VIII. ACCESSING AN ELEMENT OF A SET
• IX. PROGRAM ANALYSIS
• X. SUMMARY
• XI. REFERENCE
• XII. CONTACT ME

WHAT YOU WILL LEARN IN THIS TUTORIAL

1. You will learn the basic STL set container vocabulary.

2. You will learn how to declare a set.

3. You will learn how to declare a set iterator.

4. You will learn how to initialize a set iterator.

5. You will learn how to initialize a set.

6. You will learn how to access an element of a set.

• I. ASSUMPTIONS

Hello; nice to meet you. I assume you are a beginner who has a C++ compiler and you want to learn how to use the STL set container.

• II. INTRODUCTION

Welcome to STL set containers.

The STL set and multiset have the same member functions. Therefore, I will discuss both when appropriate during this tutorial.

• III. VOCABULARY

1. What is STL?

The standard template library (STL) is the place to go when you need information to help you write C++ programs that need frequent and fast searches. STL containers are generic template classes. Items inserted into STL containers are sorted on insertion so you can find your stuff faster.

2. What is a set or multiset iterator?

A set or multiset iterator is an object that refers to elements of a set or multiset. A set or multiset iterator can perform three operations. First, report the value in the element at the current location. Second, advance to the next element in the set or multiset. And third, step back to the previous element in the set or multiset.

3. What are STL set and multiset containers?

Sets and multisets were created to be the best choice for inserting and deleting elements, and for checking to see if a value is in the set or multiset. If you have a programming challenge that requires insertion, removal, and testing for inclusion of values you should consider solving your problem by using a set or multiset.

You have to use the #include <set> header file and instantiate the STL set and multiset template classes before you can use their member functions. Set and multiset have the same member functions. The only difference between the two containers is a set is a STL container that stores unique values and a multiset is a STL container that stores non-unique values, values with duplicates. The STL set and multiset elements default sort uses the less than < relational operator which sorts the values in ascending order.

IV. DECLARING A SET AND A MULTISET

Neither a set nor a multiset can contain a mixture of types. Any C++ type or a class you define that has both the < less than operator and the == equal to operator defined can be held in a set or a multiset.

1. Declaring a set.

A set is declared using the following syntax:

set<type> set_name;

In the attached program the set of the class defined as CTemp is declared as follows:

set<CTemp> equations;

2. Declaring a multiset

A multiset is declared using the following syntax:

multiset<type> multiset_name;

• V. DECLARING A SET OR MULTISET ITERATOR

A set or multiset iterator is declared using the following syntax:

set<type>::iterator iterator_name;

In the attached program the iterator for the set of the class defined as CTemp is declared as follows:

set<CTemp>::iterator ei;

• VI. INITIALIZE A SET OR MULTISET ITERATOR

C++ set objects include a member function called begin(). Using begin() returns an iterator to the beginning, the first element, of an ascending sorted set. A set or multiset iterator is initialized using the following syntax:

iterator_name = set_name.begin();

In the attached program the iterator named ei for the set named equations of the class defined as CTemp is initialized as follows:

ei = equations.begin();

C++ set objects also include a member function called end(). Be careful when you use end(). Using end() returns an iterator to one past the last element, of an ascending sorted set.

• VII. INITIALIZING A SET OR MULTISET

There are many ways to initialize a set or multiset.

The syntax used to initialize the set in the attached program is as follows:

set_name.insert(class_name("key", "value"));

Notice this mimics a key and a value pair. The mimic was accomplished by using the following ostream code.

ostream &operator << (ostream &os, class_name &set_name)
{
os  << "  " << set_name.m_getKeyName();						   os  << "  " << set_name.m_getValueName() << endl;	return os;
}


• VIII. ACCESSING AN ELEMENT OF A SET OR MULTISET

Accessing an element of a set uses the same syntax as used with pointers.

1. Current set or multiset element

Use the following syntax to access an element the iterator considers to be current:

*iterator_name;

In the attached program the iterator named ei would be accessed as follows:

*ei;

2. Increment and decrement operators

Increment operator advances the iterator to the next element of the set by using the following syntax:

iterator_name++;

++iterator_name;

Decrement operator moves the iterator back to the previous element of the set by using the following syntax:

iterator_name--;

--iterator_name;

3. Iterating from largest to smallest key element

To iterate in reverse order you can use the pair of reverse iterators named rbegin() and rend() using the following syntax:

set_name.rbegin(); returns an iterator to the last element of a set.

set_name.rend(); returns an iterator to one step before the first element of a set.

4. Comparing iterators

You can compare iterators by using the == and != operators.

5. Find

The syntax for the find() member function is as follows:

set_name.find(element);

If the element you are trying to find is not in the set or multiset the default return is set_name.end(), an iterator one step past the end of the set or multiset.

• IX. PROGRAM ANALYSIS

Please copy and paste the attached program into a file your compiler can read. Then build, compile, and debug the program. Following along, back and forth, between the tutorial and your copy of the program will help you understand the program.


//*****************************************************
// BEGINNER C++ STL SET AND MULTISET CONTAINER TUTORIAL
//*****************************************************
#include <algorithm>
#include <ctime> 
#include <fstream>				// Needed for file I/O.
#include <iomanip>				// Needed for format manipulation. 
#include <iostream>
#include <iterator>				//ostream_iterator
#include <map>					// Needed for STL classes map and multimap.
#include <math.h>
#include <set>					// Needed for STL set and multiset.
#include <sstream>
#include <stddef.h>
#include <stdio.h>				// I/O
#include <stdlib.h>				// Needed for converter functions.
#include <string>
#include <windows.h>
using std::istringstream;		// Needed for STL classes.
using std::ifstream;			// Needed for STL classes.
using std::string;				// Needed for STL classes.
using std::cout;				// Needed for STL classes.
using std::cin;					// Needed for STL classes.
using std::cerr;				// Needed for STL classes.

using namespace std;

//************************************
//Class CTemp
//************************************
class CTemp
{
	private:

		string Number;			  //Temperature equation number.
		string Equation;			//Temperature conversion equation.


	public:

		CTemp()					 //Constructor used when neither equation number nor conversion equation are entered.
		{
			Number = "";
			Equation = "";
		}

		CTemp(string n)			 //Constructor used when only conversion equation number is entered.				
		{
			Number = n;				//n is the temperature conversion equation number.
			Equation = "";
		}

		CTemp(string n, string e)   //Constructor used when both equation number and conversion equation are entered.
		{
			Number = n;
			Equation = e;		   //e is the temperature conversion equation.		   
		}

		string m_getNumber()		  //Gets the temperature conversion equation number.
		{
			return Number;
		}

		string m_getEquation()		//Gets the temperature conversion equation.
		{
			return Equation;
		}

		double m_CelsiusToCelsius(double FromTemp);			//Converts Celsius To Celsius.
		double m_CentigradeToCelsius(double FromTemp);		//Converts Centigrade To Celsius.
		double m_DelisleToCelsius(double FromTemp);			//Converts Delisle to Celsius.
		double m_FahrenheitToCelsius(double FromTemp);		//Converts Fahrenheit To Celsius.
		double m_KelvinToCelsius(double FromTemp);			//Converts Kelvin To Celsius.
		double m_NewtonToCelsius(double FromTemp);			//Converts Newton To Celsius.
		double m_RankineToCelsius(double FromTemp);			//Converts Rankine To Celsius.
		double m_ReaumurToCelsius(double FromTemp);			//Converts Reaumur To Celsius.
		double m_RomerToCelsius(double FromTemp);			//Converts Romer To Celsius.

		double (m_CelsiusToCentigrade)(double FromTemp);	//Converts Celsius To Centigrade.
		double (m_CentigradeToCentigrade)(double FromTemp);	//Converts Centigrade To Centigrade.
		double (m_DelisleToCentigrade)(double FromTemp);	//Converts Delisle To Centigrade.
		double (m_FahrenheitToCentigrade)(double FromTemp);	//Converts Fahrenheit To Centigrade.
		double (m_KelvinToCentigrade)(double FromTemp);		//Converts Kelvin To Centigrade.
		double (m_NewtonToCentigrade)(double FromTemp);		//Converts Newton To Centigrade.
		double (m_RankineToCentigrade)(double FromTemp);	//Converts Rankine To Centigrade.
		double (m_ReaumurToCentigrade)(double FromTemp);	//Converts Reaumur To Centigrade.
		double (m_RomerToCentigrade)(double FromTemp);		//Converts Romer To Centigrade.

		double (m_CelsiusToDelisle)(double FromTemp);		//Converts Celsius To Delisle.
		double (m_CentigradeToDelisle)(double FromTemp);	//Converts Centigrade To Delisle.
		double (m_DelisleToDelisle)(double FromTemp);		//Converts Delisle To Delisle.
		double (m_FahrenheitToDelisle)(double FromTemp);	//Converts Fahrenheit To Delisle.
		double (m_KelvinToDelisle)(double FromTemp);		//Converts Kelvin To Delisle.
		double (m_NewtonToDelisle)(double FromTemp);		//Converts Newton To Delisle.
		double (m_RankineToDelisle)(double FromTemp);		//Converts Rankine To Delisle.
		double (m_ReaumurToDelisle)(double FromTemp);		//Converts Reaumur To Delisle.
		double (m_RomerToDelisle)(double FromTemp);			//Converts Romer To Delisle.

		double (m_CelsiusToFahrenheit)(double FromTemp);	//Converts Celsius To Fahrenheit.
		double (m_CentigradeToFahrenheit)(double FromTemp);	//Converts Centigrade To Fahrenheit.
		double (m_DelisleToFahrenheit)(double FromTemp);	//Converts Delisle To Fahrenheit.
		double (m_FahrenheitToFahrenheit)(double FromTemp);	//Converts Fahrenheit To Fahrenheit.
		double (m_KelvinToFahrenheit)(double FromTemp);		//Converts Kelvin To Fahrenheit.
		double (m_NewtonToFahrenheit)(double FromTemp);		//Converts Newton To Fahrenheit.
		double (m_RankineToFahrenheit)(double FromTemp);	//Converts Rankine To Fahrenheit.
		double (m_ReaumurToFahrenheit)(double FromTemp);	//Converts Reaumur To Fahrenheit.
		double (m_RomerToFahrenheit)(double FromTemp);		//Converts Romer To Fahrenheit.

		double (m_CelsiusToKelvin)(double FromTemp);		//Converts Celsius To Kelvin.
		double (m_CentigradeToKelvin)(double FromTemp);		//Converts Centigrade To Kelvin.
		double (m_DelisleToKelvin)(double FromTemp);		//Converts Delisle To Kelvin.
		double (m_FahrenheitToKelvin)(double FromTemp);		//Converts Fahrenheit To Kelvin.
		double (m_KelvinToKelvin)(double FromTemp);			//Converts Kelvin To Kelvin.
		double (m_NewtonToKelvin)(double FromTemp);			//Converts Newton To Kelvin.
		double (m_RankineToKelvin)(double FromTemp);		//Converts Rankine To Kelvin.
		double (m_ReaumurToKelvin)(double FromTemp);		//Converts Reaumur To Kelvin.
		double (m_RomerToKelvin)(double FromTemp);			//Converts Romer To Kelvin.

		double (m_CelsiusToNewton)(double FromTemp);		//Converts Celsius To Newton.
		double (m_CentigradeToNewton)(double FromTemp);		//Converts Centigrade To Newton.
		double (m_DelisleToNewton)(double FromTemp);		//Converts Delisle To Newton.
		double (m_FahrenheitToNewton)(double FromTemp);		//Converts Fahrenheit To Newton.
		double (m_KelvinToNewton)(double FromTemp);			//Converts Kelvin To Newton.
		double (m_NewtonToNewton)(double FromTemp);			//Converts Newton To Newton.
		double (m_RankineToNewton)(double FromTemp);		//Converts Rankine To Newton.
		double (m_ReaumurToNewton)(double FromTemp);		//Converts Reaumur To Newton.
		double (m_RomerToNewton)(double FromTemp);			//Converts Romer To Newton.

		double (m_CelsiusToRankine)(double FromTemp);		//Converts Celsius To Rankine.
		double (m_CentigradeToRankine)(double FromTemp);	//Converts Centigrade To Rankine.
		double (m_DelisleToRankine)(double FromTemp);		//Converts Delisle To Rankine.
		double (m_FahrenheitToRankine)(double FromTemp);	//Converts Fahrenheit To Rankine.
		double (m_KelvinToRankine)(double FromTemp);		//Converts Kelvin To Rankine.
		double (m_NewtonToRankine)(double FromTemp);		//Converts Newton To Rankine.
		double (m_RankineToRankine)(double FromTemp);		//Converts Rankine To Rankine.
		double (m_ReaumurToRankine)(double FromTemp);		//Converts Reaumur To Rankine.
		double (m_RomerToRankine)(double FromTemp);			//Converts Romer To Rankine.

		double (m_CelsiusToReaumur)(double FromTemp);		//Converts Celsius To Reaumur.
		double (m_CentigradeToReaumur)(double FromTemp);	//Converts Centigrade To Reaumur.
		double (m_DelisleToReaumur)(double FromTemp);		//Converts Delisle To Reaumur.
		double (m_FahrenheitToReaumur)(double FromTemp);	//Converts Fahrenheit To Reaumur.
		double (m_KelvinToReaumur)(double FromTemp);		//Converts Kelvin To Reaumur.
		double (m_NewtonToReaumur)(double FromTemp);		//Converts Newton To Reaumur.
		double (m_RankineToReaumur)(double FromTemp);		//Converts Rankine To Reaumur.
		double (m_ReaumurToReaumur)(double FromTemp);		//Converts Reaumur To Reaumur.
		double (m_RomerToReaumur)(double FromTemp);			//Converts Romer To Reaumur.

		double (m_CelsiusToRomer)(double FromTemp);			//Converts Celsius To Romer.
		double (m_CentigradeToRomer)(double FromTemp);		//Converts Centigrade To Romer.
		double (m_DelisleToRomer)(double FromTemp);			//Converts Delisle To Romer.
		double (m_FahrenheitToRomer)(double FromTemp);		//Converts Fahrenheit To Romer.
		double (m_KelvinToRomer)(double FromTemp);			//Converts Kelvin To Romer.
		double (m_NewtonToRomer)(double FromTemp);			//Converts Newton To Romer.
		double (m_RankineToRomer)(double FromTemp);			//Converts Rankine To Romer.
		double (m_ReaumurToRomer)(double FromTemp);			//Converts Reaumur To Romer.
		double (m_RomerToRomer)(double FromTemp);			//Converts Romer To Romer.


		void	m_ShowTime();								//Starts program: full screen, date and time. 
		void	m_DateTime();								//Date and time.
		void	m_AltEnter();								//Full screen.
		int		m_Row();									//Row.
		int		m_Column();									//Column.
		int		m_Menu(char);								//Menu.
		void	m_DoInput(int, int);						//User input.
		double	m_Conversion(int, int, double);				//Temperature conversion.
		void	m_DisplaySet();							 //Display set.
				~CTemp();									//Destructor.

};

//**************************************************
//************************************
// 1  Converts Celsius To Celsius.
//************************************
double CTemp::m_CelsiusToCelsius(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = FromTemp;

	return ToTemp;
}

//************************************
// 2  Converts Centigrade To Celsius.
//************************************
double CTemp::m_CentigradeToCelsius(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = FromTemp;

	return ToTemp;
}

//************************************
// 3  Converts Delisle to Celsius.
//************************************
double CTemp::m_DelisleToCelsius(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (100 - ((FromTemp * 2) / 3));

	return ToTemp;
}

//************************************
// 4  Converts Fahrenheit To Celsius.
//************************************
double CTemp::m_FahrenheitToCelsius(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((FromTemp - 32) * 5) / 9);

	return ToTemp;
}

//************************************
// 5  Converts Kelvin To Celsius.
//************************************
double CTemp::m_KelvinToCelsius(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (FromTemp - 273.15);	

	return ToTemp;
}

//************************************
// 6  Converts Newton To Celsius.
//************************************
double CTemp::m_NewtonToCelsius(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = ((FromTemp * 100) / 33);	

	return ToTemp;
}

//************************************
// 7  Converts Rankine To Celsius.
//************************************
double CTemp::m_RankineToCelsius(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((FromTemp - 491.67) * 5) / 9 );

	return ToTemp;
}

//************************************
// 8  Converts Reaumur To Celsius.
//************************************
double CTemp::m_ReaumurToCelsius(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (( FromTemp * 5) / 4 );

	return ToTemp;
}

//************************************
// 9  Converts Romer To Celsius.
//************************************
double CTemp::m_RomerToCelsius(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = ((( FromTemp - 7.5) * 40) / 21 );

	return ToTemp;
}

//************************************************************************

//************************************
//10  Converts Celsius To Centigrade.
//************************************
double CTemp::m_CelsiusToCentigrade(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = FromTemp;

	return ToTemp;
}

//************************************
//11  Converts Centigrade To Centigrade.
//************************************
double CTemp::m_CentigradeToCentigrade(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = FromTemp;

	return ToTemp;
}

//************************************
//12  Converts Delisle to Centigrade.
//************************************
double CTemp::m_DelisleToCentigrade(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (100 - ((FromTemp * 2) / 3));	

	return ToTemp;
}

//************************************
//13  Converts Fahrenheit To Centigrade.
//************************************
double CTemp::m_FahrenheitToCentigrade(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((FromTemp - 32) * 5) / 9);

	return ToTemp;
}

//************************************
//14  Converts Kelvin To Centigrade.
//************************************
double CTemp::m_KelvinToCentigrade(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (FromTemp - 273.15);		

	return ToTemp;
}

//************************************
//15  Converts Newton To Centigrade.
//************************************
double CTemp::m_NewtonToCentigrade(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = ((FromTemp * 100) / 33);	

	return ToTemp;
}

//************************************
//16  Converts Rankine To Centigrade.
//************************************
double CTemp::m_RankineToCentigrade(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((FromTemp - 491.67) * 5) / 9 );

	return ToTemp;
}

//************************************
//17  Converts Reaumur To Centigrade.
//************************************
double CTemp::m_ReaumurToCentigrade(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = ((FromTemp * 5) / 4 );

	return ToTemp;
}

//************************************
//17  Converts Romer To Centigrad.
//************************************
double CTemp::m_RomerToCentigrade(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = ((( FromTemp - 7.5) * 40) / 21 );

	return ToTemp;
}

//************************************************************************

//************************************
//19  Converts Celsius To Delisle.
//************************************
double CTemp::m_CelsiusToDelisle(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((100 - FromTemp) *3) / 2);

	return ToTemp;
}

//************************************
//20  Converts Centigrade To Delisle.
//************************************
double CTemp::m_CentigradeToDelisle(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((100 - FromTemp) *3) / 2);

	return ToTemp;
}

//************************************
//21  Converts Delisle to Delisle.
//************************************
double CTemp::m_DelisleToDelisle(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = FromTemp;	

	return ToTemp;
}

//************************************
//22  Converts Fahrenheit To Delisle.
//************************************
double CTemp::m_FahrenheitToDelisle(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((212 - FromTemp) * 5) / 6);

	return ToTemp;
}

//************************************
//23  Converts Kelvin To Delisle.
//************************************
double CTemp::m_KelvinToDelisle(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((373.15 - FromTemp) * 3) / 2);		

	return ToTemp;
}

//************************************
//24  Converts Newton To Delisle.
//************************************
double CTemp::m_NewtonToDelisle(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((33 - FromTemp) * 50) / 11);	

	return ToTemp;
}

//************************************
//25  Converts Rankine To Delisle.
//************************************
double CTemp::m_RankineToDelisle(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((671.67 - FromTemp) * 5) / 6);

	return ToTemp;
}

//************************************
//26  Converts Reaumur To Delisle.
//************************************
double CTemp::m_ReaumurToDelisle(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = ((( 80 - FromTemp) * 15 ) / 8 );

	return ToTemp;
}

//************************************
//27  Converts Romer To Delisle.
//************************************
double CTemp::m_RomerToDelisle(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = ((( 60 - FromTemp) * 20 ) / 7 );

	return ToTemp;
}

//************************************************************************

//************************************
//28  Converts Celsius To Fahrenheit.
//************************************
double CTemp::m_CelsiusToFahrenheit(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((FromTemp * 9) / 5) + 32);

	return ToTemp;
}

//************************************
//29  Converts Centigrade To Fahrenheit.
//************************************
double CTemp::m_CentigradeToFahrenheit(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((FromTemp * 9) / 5) + 32);

	return ToTemp;
}

//************************************
//30  Converts Delisle to Fahrenheit.
//************************************
double CTemp::m_DelisleToFahrenheit(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (212 - ((FromTemp * 6) / 5));	

	return ToTemp;
}

//************************************
//31  Converts Fahrenheit To Fahrenheit.
//************************************
double CTemp::m_FahrenheitToFahrenheit(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = FromTemp;

	return ToTemp;
}

//************************************
//32  Converts Kelvin To Fahrenheit.
//************************************
double CTemp::m_KelvinToFahrenheit(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((FromTemp * 9) / 5) - 459.67);		

	return ToTemp;
}

//************************************
//33  Converts Newton To Fahrenheit.
//************************************
double CTemp::m_NewtonToFahrenheit(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((FromTemp * 60) / 11) + 32);

	return ToTemp;
}

//************************************
//34  Converts Rankine To Fahrenheit.
//************************************
double CTemp::m_RankineToFahrenheit(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (FromTemp - 459.67 );

	return ToTemp;
}

//************************************
//35  Converts Reaumur To Fahrenheit.
//************************************
double CTemp::m_ReaumurToFahrenheit(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = ((( FromTemp * 9) / 4) + 32 );

	return ToTemp;
}

//************************************
//36  Converts Romer To Fahrenheit.
//************************************
double CTemp::m_RomerToFahrenheit(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((( FromTemp - 7.5) * 24) / 7 ) + 32 );

	return ToTemp;
}

//************************************************************************

//************************************
//37  Converts Celsius To Kelvin.
//************************************
double CTemp::m_CelsiusToKelvin(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = ((FromTemp) + (273.15));

	return ToTemp;
}

//************************************
//38  Converts Centigrade To Kelvin.
//************************************
double CTemp::m_CentigradeToKelvin(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = ((FromTemp) + (273.15));

	return ToTemp;
}

//************************************
//39  Converts Delisle to Kelvin.
//************************************
double CTemp::m_DelisleToKelvin(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (373.15 - ((FromTemp * 2) / 3));	

	return ToTemp;
}

//************************************
//40  Converts Fahrenheit To Kelvin.
//************************************
double CTemp::m_FahrenheitToKelvin(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((FromTemp + 459.67) *5) /9);;

	return ToTemp;
}

//************************************
//41  Converts Kelvin To Kelvin.
//************************************
double CTemp::m_KelvinToKelvin(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = FromTemp;		

	return ToTemp;
}

//************************************
//42  Converts Newton To Kelvin.
//************************************
double CTemp::m_NewtonToKelvin(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((FromTemp * 100) / 33 ) + 273.15);

	return ToTemp;
}

//************************************
//43  Converts Rankine To Kelvin.
//************************************
double CTemp::m_RankineToKelvin(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = ((FromTemp * 5) / 9 );

	return ToTemp;
}

//************************************
//44  Converts Reaumur To Kelvin.
//************************************
double CTemp::m_ReaumurToKelvin(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = ((( FromTemp * 5) / 4) +  273.15 );

	return ToTemp;
}

//************************************
//45  Converts Romer To Kelvin.
//************************************
double CTemp::m_RomerToKelvin(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((( FromTemp - 7.5) * 40 ) / 21 ) + 273.15 );

	return ToTemp;
}

//************************************************************************

//************************************
//46  Converts Celsius To Newton.
//************************************
double CTemp::m_CelsiusToNewton(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = ((FromTemp * 33) / 100);

	return ToTemp;
}

//************************************
//47  Converts Centigrade To Newton.
//************************************
double CTemp::m_CentigradeToNewton(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = ((FromTemp * 33) / 100);

	return ToTemp;
}

//************************************
//48  Converts Delisle to Newton.
//************************************
double CTemp::m_DelisleToNewton(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (33 - ((FromTemp * 11) / 50));	

	return ToTemp;
}

//************************************
//49  Converts Fahrenheit To Newton.
//************************************
double CTemp::m_FahrenheitToNewton(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((FromTemp - 32) * 11) / 60);	
	return ToTemp;
}

//************************************
//50  Converts Kelvin To Newton.
//************************************
double CTemp::m_KelvinToNewton(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((FromTemp - 273.15) * 33) / 100);		

	return ToTemp;
}

//************************************
//51  Converts Newton To Newton.
//************************************
double CTemp::m_NewtonToNewton(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = FromTemp;

	return ToTemp;
}

//************************************
//52  Converts Rankine To Newton.
//************************************
double CTemp::m_RankineToNewton(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((FromTemp - 491.67) * 11) / 60 ); 

	return ToTemp;
}

//************************************
//53  Converts Reaumur To Newton.
//************************************
double CTemp::m_ReaumurToNewton(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (( FromTemp * 33 ) / 80 );
	return ToTemp;
}

//************************************
//54  Converts Romer To Newton.
//************************************
double CTemp::m_RomerToNewton(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = ((( FromTemp - 7.5 ) * 22) / 35 );

	return ToTemp;
}

//************************************************************************

//************************************
//55  Converts Celsius To Rankine.
//************************************
double CTemp::m_CelsiusToRankine(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((FromTemp * 9) / 5) + (491.67));

	return ToTemp;
}

//************************************
//56  Converts Centigrade To Rankine.
//************************************
double CTemp::m_CentigradeToRankine(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((FromTemp * 9) / 5) + (491.67));

	return ToTemp;
}

//************************************
//57  Converts Delisle to Rankine.
//************************************
double CTemp::m_DelisleToRankine(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (671.67 - ((FromTemp * 6) / 5));

	return ToTemp;
}

//************************************
//58  Converts Fahrenheit To Rankine.
//************************************
double CTemp::m_FahrenheitToRankine(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (FromTemp + 459.67);
	return ToTemp;
}

//************************************
//59  Converts Kelvin To Rankine.
//************************************
double CTemp::m_KelvinToRankine(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = ((FromTemp * 9) / 5);	

	return ToTemp;
}

//************************************
//60  Converts Newton To Rankine.
//************************************
double CTemp::m_NewtonToRankine(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((FromTemp * 60) / 11) + 491.67);

	return ToTemp;
}

//************************************
//61  Converts Rankine To Rankine.
//************************************
double CTemp::m_RankineToRankine(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = FromTemp; 

	return ToTemp;
}

//************************************
//62  Converts Reaumur To Rankine.
//************************************
double CTemp::m_ReaumurToRankine(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = ((( FromTemp * 9) / 4 ) + 491.67 );
	return ToTemp;
}

//************************************
//63  Converts Romer To Rankine.
//************************************
double CTemp::m_RomerToRankine(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((( FromTemp - 7.5 ) * 24 ) / 7 ) + 491.67 );

	return ToTemp;
}

//************************************************************************

//************************************
//64  Converts Celsius To Reaumur.
//************************************
double CTemp::m_CelsiusToReaumur(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = ((FromTemp * 4) / 5);

	return ToTemp;
}

//************************************
//65  Converts Centigrade To Reaumur.
//************************************
double CTemp::m_CentigradeToReaumur(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = ((FromTemp * 4) / 5);

	return ToTemp;
}

//************************************
//66  Converts Delisle to Reaumur.
//************************************
double CTemp::m_DelisleToReaumur(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (80 - ((FromTemp * 8) / 15));

	return ToTemp;
}

//************************************
//67 Converts Fahrenheit To Reaumur.
//************************************
double CTemp::m_FahrenheitToReaumur(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((FromTemp - 32) * 4) / 9);
	return ToTemp;
}

//************************************
//68  Converts Kelvin To Reaumur.
//************************************
double CTemp::m_KelvinToReaumur(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((FromTemp - 273.15) * 4) / 5);	

	return ToTemp;
}

//************************************
//69  Converts Newton To Reaumur.
//************************************
double CTemp::m_NewtonToReaumur(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = ((FromTemp * 80) / 33 );

	return ToTemp;
}

//************************************
//70  Converts Rankine To Reaumur.
//************************************
double CTemp::m_RankineToReaumur(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((FromTemp - 491.67) * 4) / 9 );

	return ToTemp;
}

//************************************
//71  Converts Reaumur To Reaumur.
//************************************
double CTemp::m_ReaumurToReaumur(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = FromTemp;
	return ToTemp;
}

//************************************
//72  Converts Romer To Reaumur.
//************************************
double CTemp::m_RomerToReaumur(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = ((( FromTemp - 7.5 ) * 32 ) / 21 );

	return ToTemp;
}

//************************************************************************

//************************************
//73  Converts Celsius To Romer.
//************************************
double CTemp::m_CelsiusToRomer(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((FromTemp * 21) / 40) + 7.5);

	return ToTemp;
}

//************************************
//74  Converts Centigrade To Romer.
//************************************
double CTemp::m_CentigradeToRomer(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (((FromTemp * 21) / 40) + 7.5);

	return ToTemp;
}

//************************************
//75  Converts Delisle to Romer.
//************************************
double CTemp::m_DelisleToRomer(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = (60 - ((FromTemp * 7) / 20));

	return ToTemp;
}

//************************************
//76  Converts Fahrenheit To Romer.
//************************************
double CTemp::m_FahrenheitToRomer(double FromTemp)
{
	double ToTemp = 0;

	ToTemp = ((((FromTemp - 32) * 7) / 24) + 7.5);

	return ToTemp;
}

//************************************
//77  Converts Kelvin To Romer.
//************************************
double CTemp::m_KelvinToRomer(double FromTemp)
{
	double


Is This A Good Question/Topic? 1
  • +

Replies To: BEGINNER C++ STL SET CONTAINER TUTORIAL

#2 Guest_dubious*


Reputation:

Posted 28 March 2010 - 03:39 PM

if it's for beginner c++ set
why so long example? for what ? mean what? you are great? :bananaman:
Was This Post Helpful? 2

#3 Elcric  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 101
  • View blog
  • Posts: 453
  • Joined: 02-May 09

Posted 02 April 2010 - 10:44 AM

View Postdubious, on 28 March 2010 - 04:39 PM, said:

if it's for beginner c++ set
why so long example? for what ? mean what? you are great? :bananaman:


Hello Dubious!

I agree with you. I see now that long code examples, like mine, are automatically truncated by the system. I will use shorter examples from now on that fit within the example file size.

Thanks for your comments!

Was This Post Helpful? 1
  • +
  • -

#4 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Posted 02 April 2010 - 11:20 AM

You can also just add a text file as an attachment with all the code. That will also alleviate the issue.
Was This Post Helpful? 1
  • +
  • -

#5 Elcric  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 101
  • View blog
  • Posts: 453
  • Joined: 02-May 09

Posted 15 May 2010 - 10:10 AM

Hello Jayman,

Excellent suggestion. I will keep that in mind. Thank you very much!

Was This Post Helpful? 1
  • +
  • -

#6 Xupicor  Icon User is offline

  • Nasal Demon
  • member icon

Reputation: 249
  • View blog
  • Posts: 582
  • Joined: 31-May 11

Posted 02 June 2011 - 08:13 AM

Quote

Items inserted into STL containers are sorted on insertion so you can find your stuff faster.
This is of course wrong, see std::list, std::deque, or std::vector. You surely meant std::set, std::map, etc, but what you wrote is misleading, and just plain wrong. It'd be great if you could fix that. :)

Also, do you really need 1100+ lines example code that most of the times does other things than represent how to use std::set, which I'd imagine should be its main purpose?
Was This Post Helpful? 0
  • +
  • -

#7 Elcric  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 101
  • View blog
  • Posts: 453
  • Joined: 02-May 09

Posted 01 August 2011 - 09:00 AM

Hello Xupicor,

Thank you for your comments:

View PostXupicor, on 02 June 2011 - 11:13 AM, said:

Quote

Items inserted into STL containers are sorted on insertion so you can find your stuff faster.


This is of course wrong, see std::list, std::deque, or std::vector. You surely meant std::set, std::map, etc, but what you wrote is misleading, and just plain wrong. It'd be great if you could fix that. :)

Also, do you really need 1100+ lines example code that most of the times does other things than represent how to use std::set, which I'd imagine should be its main purpose?


You are correct, I goofed, I am very sorry! I intended the sentence to read, "Items inserted into STL std::set containers are sorted on insertion so you can find your stuff faster." I did not catch the error when I edited the tutorial. Thank you very much for catching the error.

And, you are correct in saying I did not really need 1100+ lines of example code. I promise you the tutorials I write in the future will be concise.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1