# Register now to access 7 million high quality study materials (What's Course Hero?) Course Hero is the premier provider of high quality online educational resources. With millions of study documents, online tutors, digital flashcards and free courseware, Course Hero is helping students learn more efficiently and effectively. Whether you're interested in exploring new subjects or mastering key topics for your next exam, Course Hero has the tools you need to achieve your goals.

3 Pages

### vector-iterators

Course: ECE 3090, Spring 2012
School: Georgia Tech
Rating:

Word Count: 493

#### Document Preview

Demonstrate // the use of the Standard Template Library &quot;vector&quot; class. // and associated iterators, and templated subroutines // George F. Riley, ECE3090 Georgia Tech, Fall 2009 #include #include #include #include &lt;iostream&gt; &lt;vector&gt; &lt;algorithm&gt; &lt;iterator&gt; using namespace std; typedef vector&lt;char&gt; CharVec_t; // Define a...

Register Now

#### Unformatted Document Excerpt

Coursehero >> Georgia >> Georgia Tech >> ECE 3090

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
Demonstrate // the use of the Standard Template Library "vector" class. // and associated iterators, and templated subroutines // George F. Riley, ECE3090 Georgia Tech, Fall 2009 #include #include #include #include <iostream> <vector> <algorithm> <iterator> using namespace std; typedef vector<char> CharVec_t; // Define a vector of character class Wheels { public: Wheels(const char* n, int c); // Constructor with name and cost bool operator<(const Wheels& rhs); // Define a less than operator public: int cost; CharVec_t name; // Use char vector to store name (variable length) }; // Wheels constructor // This demonstrates the use of the vector constructor that takes // two iterators and pushes all of the specified items on the vector. // Also notice that "char*" is not a subclass of iterator, but this // works anyway. Think about why this works Wheels::Wheels(const char* n, int c) : cost(c), name(n, n + strlen(n)) { // while(*n) name.push_back(*n++); // Add the name characters to name vector } // Wheels comparator bool Wheels::operator<(const Wheels& rhs) { // Less than is defined as less cost return cost < rhs.cost; } typedef vector<Wheels> WheelsVec_t; // Define a vector of cars // Define output operators for CharVec_t and Wheels ostream& operator<<(ostream& os, CharVec_t& cv) { // Output each character for (CharVec_t::size_type i = 0; i < cv.size(); ++i) os << cv[i]; return os; } ostream& operator<<(ostream& os, Wheels& car) { os << "Name " << car.name << " cost " << car.cost; return os; } // Define a subroutine to print an arbitrary vector template <class ForwardIterator> void PrintVec(ForwardIterator b, ForwardIterator e, bool addEndl = true) { } while(b != e) { cout << (*b++); if (addEndl) cout << endl; } template <class ForwardIterator> Sort(ForwardIterator void b, ForwardIterator e) { // This sort is inefficient, and used for illustrative purposes only while(b != e) { ForwardIterator i = b; while(i != e) { if (*i < *b) { // Need to swap. This iter_swap is defined in "algorithm" iter_swap(i, b); // Swap the two value. } ++i; } ++b; } } int main() { WheelsVec_t cars; // Maintain a vector of cars cars.push_back(Wheels("Ferrari", 150000)); cars.push_back(Wheels("Toyota", 18000)); cars.push_back(Wheels("Yugo", 10000)); cars.push_back(Wheels("Volkswagon", 15000)); cars.push_back(Wheels("Ford", 20000)); cars.push_back(Wheels("Chrysler", 30000)); cars.push_back(Wheels("Mercedes", 60000)); // Print each car using the indexing operator and integer index cout << "Printing indexing operator" << endl; for (WheelsVec_t::size_type i = 0; i < cars.size(); ++i) { cout << cars[i] << endl; } // Print each car using iterators cout << "Print using Iterators" << endl; WheelsVec_t::iterator it = cars.begin(); // Points to first element while(it != cars.end()) { // Loop until end reached cout << (*it++) << endl; } cout << "Printing using the PrintVec subroutine" << endl; // Use the PrintVec templated subroutine PrintVec(cars.begin(), cars.end()); // Sort the values Sort(cars.begin(), cars.end()); cout << "After sorting" << endl; PrintVec(cars.begin(), cars.end()); // Illustrate sorting of a character array const char* testch = "HelloThisIsATest"; // Allocate memory for a copy of this string char* testch1 = new char[strlen(testch) + 1]; // Copy the string strcpy(testch1, testch); cout << "Before sort " << testch1 << endl; Sort(testch1, testch1 + strlen(testch1)); cout << "After sort " << testch1 << endl; }
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Georgia Tech - ECE - 3090
/ Demonstrate the use of the Standard Template Library &quot;vector&quot; class. / George F. Riley, ECE3090 Georgia Tech, Fall 2009 / A vector is a variable length array. It starts out as &quot;zero&quot; length / and grows or shrinks as needed. Further, the vector is a arra
Georgia Tech - ECE - 3090
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56/ Demonstrate the use of the Standard Template Library &quot;vector&quot; class. / and associated iterator
Georgia Tech - ECE - 3090
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56/ Demonstrate the use of the Standard Template Library &quot;vector&quot; class. / George F. Riley, ECE309
Georgia Tech - ECE - 3090
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56/ Example illustrating Subclassing with virtual functions / ECE3090 / George F. Riley, Georgia T
Georgia Tech - ECE - 3090
C+SearchSearch:InformationGeneral information about the C+programming language, including nontechnical documents and descriptions:cplusplus.com Description of the C+ language History of the C+ language F.A.Q., Frequently Asked QuestionsInformati
Palm Beach Community College - HEALTH - HSC 2100
Brooke Sparks16th April 2012HSC2130T&amp;Th 3:30-4:45Genital human papillomavirus, also known as HPV for short, is the most commonsexually transmitted infection (STI) in the United States. This infection is viral. There are morethan 40 types of HPV that
NYU - ECON - ECON-UA 10
NYU - ECON - ECON-UA 10
NYU - ECON - ECON-UA 10
Hartford - AC - 321
Weaver General Store, Inc.Student # 1:Student # 2:Instructions1. Using the Chart of Accounts provided, record the transactions in the General Journal. Do not add new accounts.2. Post the General Journal entries to the General Ledger.3. Prepare the U
NYU - SOCIAL WOR - 101
AxisIisreservedforclinicaldisordersanddevelopmentalandlearning disorders.DisordersthatmaybepresentonAxisIinclude:PanicDisorderGeneralizedAnxietyDisorderSocialPhobiaObsessiveCompulsiveDisorderPosttraumaticStressDisorderSpecificPhobiaAxisIIisforpers
Lovely Professional University - BUISENESS - mgt 511
CAPITALMARKETCAPITAL MARKETPROLOGUEPROLOGUECapital markets are a sub-part of the financialsystem. Conceptually, the financial systemincludes a complex of institutions andmechanism which affects the generation ofsavings and their transfers to thos
Lovely Professional University - BUISENESS - mgt 511
COMPETITIONLAWSININDIACompetition Isasituationinamarketinwhichfirmsor sellers independently strive for thebuyerspatronageinordertoachieveaparticular business objective forexample,profits,salesormarketshareContd Is the foundation of an efficient w
Lovely Professional University - BUISENESS - mgt 511
Industrial FinanceDefine-Industrial Refersto a company or firms that engageslargely or exclusively in the manufacture ofproducts. An industrial company, forexample, makes a good, which it then sellseither to retailers or directly to consumersSourc
Lovely Professional University - BUISENESS - mgt 511
Industries Developmentand RegulationandIntroductionIntroductionObject of industrialisation to attainhigher levels of economic well-beingGLoalisation, liberalisation andderegulationAdaptability of each country dependslargely on ability of each co
Lovely Professional University - BUISENESS - mgt 511
MONETARY AND FISCALPOLICIESInflationInflation is a rise in the generallevel of prices of goods andservices in an economy over aperiod of time. When the pricelevel rises, each unit of currencybuys fewer goods and services. Achief measure of price
Lovely Professional University - BUISENESS - mgt 511
Intellectual property rightsIntellectualLegislativeFrameworkofIPAdministrationLegislativeFrameworkofIPAdministrationDepartment of IP &amp;P coversThe Patents Act, 1970 (as amended in 2005)The Patents Rules, 2003 (as amended in 2006)The Designs Act, 200
Lovely Professional University - BUISENESS - mgt 511
Case studyReliance Industries Ltd.By:Abhishek AgarwalRB18B2A07Ahana KaushalRB18B2A09Summary Of CaseReliance the biggest private owned group of IndiaFounded by Dhirubhai H Ambani in 1967 .Involved in production of oil and gases refining andmarket
Lovely Professional University - BUISENESS - mgt 511
PublicsectorIntro The part of the economy that is owned bythe state or that it is communally owned,including the national provincial and localauthorities and public entities. One of the three sectors of the economy,consisting of government and gove
Lovely Professional University - BUISENESS - mgt 511
Small Scale and Village IndustryAll the industrial policy resolutions have emphasized theimportance of developing the village and small industries. TheSmall scale industries have a place of pride in our economy.They have a high potential for generatin
Lovely Professional University - BUISENESS - mgt 511
Stock Exchange The stock exchange is a highly organised market for the purchase and saleof second hand quoted or listed securities. Stock exchange is a market inwhich securities are bought and sold and it is an essential component of adeveloped capita
Lovely Professional University - MANAGEMENT - mgt 511
EconomicPlanningInIndiaIntroductionTheperiodfrom1947tomid1950sPreparatoryPhaseinPlanningfordevelopmentFrom1950sto1960sRapidIndustrializationLate1960s&amp;1970sPlansfocusedonAgriculturePhaseofLiberalizationstartingtentativelyinthe1980s&amp;gearingupfrom1991
Lovely Professional University - MANAGEMENT - mgt 511
Employee participation inmanagement(Business environment)Introduction:Three groups of managerialdecisions affect the workers ofany industry:Economic decisions methodsof manufacturing, automation,The main implications of workersparticipation in m
Lovely Professional University - MANAGEMENT - mgt 511
Exitpolicyreferstothepolicyregardingtheretrenchmentofsurplusmanpowerresultingfromrestructuringofindustrialunitsortheworkersbecomingunemployedbytheclosureofsickunits.Theterm'exit'istheobverseoftheterm'entry'intoindustry.Itreferstotherightorabilityofa
Lovely Professional University - MANAGEMENT - mgt 511
Foreign Direct InvestmentForeignForeign Direct InvestmentForeign Foreigndirect investment (FDI): a firminvests directly in foreign facilitiesAfirm that engages in FDI becomes amultinational enterprise (MNE) Multinational = more than one country
Lovely Professional University - MANAGEMENT - mgt 511
INDUSTRIAL RELATIONS&amp;LABOR LAWSDEFINING IR Industrial relations encompasses a set ofphenomena, both inside and outside theworkplace, concerned with determiningand regulating employment relationship Relationship between management andemployees or
Lovely Professional University - MANAGEMENT - mgt 511
Lovely Professional University - MANAGEMENT - mgt 511
Boğaziçi University - FINANCE - 257
CHAPTER 11Cash Flow Estimation andEvaluation for a ReplacementProject1Replacement Project ExampleRequired rate of return (Cost of Capital) = 11%Tax rate = 35%Original MachineBook value = 100,000Resale value today = 80,000Resale Value in 4 years
Boğaziçi University - FINANCE - 257
Chapter 9Making CapitalInvestmentDecisions0McGraw-Hill/IrwinCopyright 2008 by The McGraw-Hill Companies, Inc. All rights reserved.119 -NC-1Key Concepts and Skills Understand how to determine the relevantcash flows for a proposed investment Und
Boğaziçi University - FINANCE - 257
1-1 8-1Key Concepts and Skills Understand the payback rule and itsshortcomings Understand the internal rate of return andits strengths and weaknesses Understand the net present value rule andwhy it is the best decision criteriaChapter 8Net Presen
Boğaziçi University - FINANCE - 257
BA 2204 and BAS 324Human Resource ManagementWork flows and job analysisInstructor: ar Topal1Work: organizational perspectiveStrategy and organizationalstructure shaping structureStrategyStrategyand structure shaping HRstrategies and work flows
Boğaziçi University - FINANCE - 257
1-1 7-1Key Concepts and Skills Understand how stock prices depend onfuture dividends and dividend growth Be able to compute stock prices using thedividend growth model Understand how corporate directors areelected Understand how stock markets work
Boğaziçi University - FINANCE - 257
116 -NC-1Key Concepts and Skills Know the important bond features andbond types Understand bond values and why theyfluctuate Understand bond ratings and what theymean Understand the impact of inflation oninterest rates Understand the term struc
Boğaziçi University - FINANCE - 257
Chapter 7Equity Markets andStock Valuation0McGraw-Hill/IrwinCopyright 2008 by The McGraw-Hill Companies, Inc. All rights reserved.1-1 7-1Key Concepts and Skills Understand how stock prices depend onfuture dividends and dividend growth Be able to
Boğaziçi University - FINANCE - 257
Chapter 3Understanding Equal Opportunity and the Legal EnvironmentOBJECTIVE QUESTIONS1.The HR departments legal responsibilities include:a) monitoring the companys HR decisions.b) rendering legal opinions as to the appropriateness of HR-related deci
Boğaziçi University - FINANCE - 257
Chapter 4Managing DiversityOBJECTIVE QUESTIONS:1.You are the HRM manager in a company with a highly diverse workforce. Overlunch you are explaining to a Caucasian, middle-class, line manager that she needsto use different training techniques with he
Boğaziçi University - FINANCE - 257
Chapter 5Recruiting and Selecting EmployeesOBJECTIVE QUESTIONS1.Carmen is working through a process to ensure her company of the right number ofpeople with the right skills to meet their goals in delivering service and outputs totheir customers. Car
Boğaziçi University - FINANCE - 257
Chapter 6Managing Employee Separations, Downsizing, and OutplacementOBJECTIVE QUESTIONS1.During the late 1990s and the early 2000s, which of the following was true of thebusiness and employment environment?a) Involuntary separations increased by 30%
Boğaziçi University - FINANCE - 257
Chapter 7Appraising and Managing PerformanceOBJECTIVE QUESTIONS1.Which of the following is a comprehensive list of the functions in performanceassessment?a) Identifying, measuring, and managing human performance in organizations.b) Identifying, det
Boğaziçi University - FINANCE - 257
AchievingSuccessThroughEffectiveBusinessCommunicationBusiness Communication Today, 9e 1 - 1ChapterAchievingSuccessinTodaysCompetitiveEnvironmentWriting ClearlyWriting ClearlyCompeting for JobsCompeting for JobsSpeaking SkillfullySpeaking Skill
Boğaziçi University - FINANCE - 257
Boğaziçi University - FINANCE - 257
Boğaziçi University - FINANCE - 257
Boğaziçi University - FINANCE - 257
WritingRoutineandPositiveMessagesBusiness Communication Today, 9e 8 - 1ChapterThreeStepWritingProcessPlanningAnalyze SituationAnalyze SituationGather InformationGather InformationSelect MediumSelect MediumGet OrganizedGet OrganizedWritingAd
Boğaziçi University - FINANCE - 257
Boğaziçi University - FINANCE - 257
WritingWritingPersuasiveMessagesBusiness Communication Today, 9e 10 ChapterThreeStepWritingProcessPlanningAnalyze SituationAnalyze SituationGather InformationGather InformationSelect MediumSelect MediumGet OrganizedGet OrganizedWritingAdapt
Boğaziçi University - FINANCE - 257
CHAPTER 7EQUITY MARKETS AND STOCKVALUATIONAnswers to Concepts Review and Critical Thinking Questions1.The value of any investment depends on its cash flows; i.e., what investors will actually receive. Thecash flows from a share of stock are the divi
Boğaziçi University - FINANCE - 257
BA 2802 Principles of Finance Section IIFormulae Sheet for the Second Interim ExamSpring 2011ROE * b1 ROE * b1.Sustainable Growth Rate =2.Internal Growth Rate =3.(1 + Nominal) = (1 + Real)(1 + Inflation)4.PV6.11 (1 r ) n PVA PMTr8.Annu
Boğaziçi University - FINANCE - 257
BA 2802 PRINCIPLES OF FINANCESpring 2012First Graded Homework Due on March 27, 2012 by 17:00.1.Today is your first day as an analyst for Goldman Sachs. Your boss wants to meet in one hour todiscuss NetworKing, which manufactures equipment for interne
Boğaziçi University - FINANCE - 257
BA 2204 and BAS 324Human Resource ManagementTrainingInstructor: ar Topal1Training vs. developmentTraining Focus on the current job Scope as individual employees Short-term horizonDevelopment Focus on both the current job and futurejobs Scope
Boğaziçi University - FINANCE - 257
BA 2802 PRINCIPLES OF FINANCESolutions to Problems of the Recitation Hour on April 10, 20121.Coupon Payment = 10000.09 = \$90 very yearRemaining time to maturity = 10 yearsBond Price = \$1,140.42a.This is a premium bond. So, YTM&lt;coupon rate. So lets
Boğaziçi University - FINANCE - 257
BA 2802 Principles of FinanceProblems for Recitation hour on April 10, 20121.Bond A has 10 years to maturity and a 9% coupon rate. The bond makes annual couponpayments and has a market price of \$1,140.47.a.Calculate the yield to maturity of this bon
Boğaziçi University - FINANCE - 257
BA 2802 Principles of FinanceSolutions to Problems of Recitation hour on April 17, 20121) R=10%a)NPV 11,000 39 ,000440 ,180217 ,520 2 ,00023( 1 .10 ) ( 1 .10 )( 1 .10 )( 1 .10 )4NPV=\$479,390.5Since NPV is positive, accept the project.b) 0
Boğaziçi University - FINANCE - 257
BA 2802 Principles of FinanceProblems for Recitation hour on April 17, 20121. The ABC Company is thinking about investing in a project, project A. The summaryof cash flows from the project A is given below. The required rate of return for theprojects
Boğaziçi University - FINANCE - 257
Microsoft Visual Studio Solution File, Format Version 11.00# Visual Studio 2010Project(&quot;cfw_F184B08F-C81C-45F6-A57F-5ABD9991F28F&quot;) = &quot;YearShow_Class&quot;,&quot;YearShow_Class\YearShow_Class.vbproj&quot;, &quot;cfw_5303298E-1F26-4935-A9D9-E7CEA3F7EB3E&quot;EndProjectGlobal
Boğaziçi University - VISUAL BAS - 1292
BA 1306/BAS 132 Information Sytems and Programing Name :_Spring 2009 MidtermID# :_Question 1 (15 points)Write the output of the following program in the form given below. Textbox1 is the larger boxat the top, and Textbox2 is the smaller box at the bo
Boğaziçi University - VISUAL BAS - 1292
Write a VB program that will:1.2.3.4.5.6.Get a number from the userGet the increment from the userAsk the user if he/she wants to count forward or backwardIf the answer is forward, count from zero to the number given by the incrementIf the answ