Sponsored Content
Top Forums Programming Map with struct as key and vector as value Post 302917423 by yifangt on Tuesday 16th of September 2014 05:47:39 PM
Old 09-16-2014
To make your structure usable in a map, you should define an 'operator <' for it.
How to do so can be fiendishly complex for complicated data, since you first need a coherent definition of what 'less' even means when comparing two student class records.
Definitely I under-estimated the challenge.
Did not realize this only after another two hours of googling/reading. In my original post there were too many errors to be listed here when I tried to compile. which really discouraged me! (Better now.)
Thanks a lot!

---------- Post updated at 05:41 PM ---------- Previous update was at 02:26 PM ----------

Kind of got lost after discussions and searching.
Originally intended output is like:
Code:
---------------------
2333021 Bokow,R. 
                 NS201 3 A
                 MG342 3 A
                 FA302 1 A 
2574063 Failin,D. 
                 MK106 3 C
                 MA208 3 B
                 CP101 2 B
2663628 Kingsley,M. 
                 QA140 3 A 
                 EQ521 3 A
                 MK341 3 A
                 CP101 3 B

So
1) I want student_ID be the key for the courses and names.
2) The records are read from a fstream which contains hundreds of thousands rows, imagine from a university record.
3) Also the student_ID may NOT be clustered together one row after another, so that read in record from file need to be checked for each entry before it is pushed into map.

Last edited by yifangt; 09-16-2014 at 06:47 PM..
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Pressing backspace key simulates enter key

Hi, Whenever i press the backspace key, a new line appears, i.e. it works like a enter key. :confused: Thanks (2 Replies)
Discussion started by: vibhor_agarwali
2 Replies

2. Programming

Vector Traversing

Hi i have the following structure struct S { char Mod_num; char val; char chr_nm_cd; } I am reading a 2GB file and inserting into the structure and writing into a vector. I feel like only vector will be a right option. I tried with multimap but it is memory intensive and hence i... (1 Reply)
Discussion started by: dhanamurthy
1 Replies

3. UNIX for Dummies Questions & Answers

How to access a struct within a struct?

Can someone tell me how to do this? Just a thought that entered my mind when learning about structs. First thought was: struct one { struct two; } struct two { three; } one->two->three would this be how you would access "three"? (1 Reply)
Discussion started by: unbelievable21
1 Replies

4. Programming

C++ Map using a Vector as a Value Type?

I modified some code I found on Wikipedia concerning maps to see if it would work before applying it to a project I'm working on that has a similar idea. What I would want is for a user to be able to enter sentences and then be able to distinguish how many times a the person entered a word in a... (4 Replies)
Discussion started by: kcgb20
4 Replies

5. Solaris

Solaris 8 ssh public key authentication issue - Server refused our key

Hi, I've used the following way to set ssh public key authentication and it is working fine on Solaris 10, RedHat Linux and SuSE Linux servers without any problem. But I got error 'Server refused our key' on Solaris 8 system. Solaris 8 uses SSH2 too. Why? Please help. Thanks. ... (1 Reply)
Discussion started by: aixlover
1 Replies

6. Programming

Storing C++-struct in file - problem when adding new item in struct

Hi, I have received an application that stores some properties in a file. The existing struct looks like this: struct TData { UINT uSizeIncludingStrings; // copy of Telnet data struct UINT uSize; // basic properties: TCHAR szHost; //defined in Sshconfig UINT iPortNr; TCHAR... (2 Replies)
Discussion started by: Powerponken
2 Replies

7. Programming

Array and Vector

Hi all, from my understanding I understand that I can use array in this manner. struct test { int a; int b; int c; }; test testing; //creating an array with the structer type testing.a=1; testing.b=2; testing.c=3; If I'm not wrong we can use array in this manner,... (12 Replies)
Discussion started by: vinzping
12 Replies

8. Programming

vector c++

hello guys. i'm new to c++. i've problem using two dimensional vector. i've a project of making conway's game of life. this is the code that i have made so far. my problem is how can i give a two dimensional vector through main. glider.vec1 = vec; is not correct way to give a two... (2 Replies)
Discussion started by: nishrestha
2 Replies

9. Shell Programming and Scripting

Vector normalisation

In AWK For 3 individual vectors of the form: -2.772 -9.341 -2.857 -5.140 -6.597 -1.823 -2.730 -5.615 1.159 I would like to write a script that parses line by line to (i) normalise, (ii) divide by the norm for *each* vector. I.e. sqrt(-2.772^2 + -9.341^2 + -2.857^2)=10.154 ... (4 Replies)
Discussion started by: chrisjorg
4 Replies
rmfree(9F)						   Kernel Functions for Drivers 						rmfree(9F)

NAME
rmfree - free space back into a resource map SYNOPSIS
#include <sys/map.h> #include <sys/ddi.h> void rmfree(struct map *mp, size_t size, ulong_t index); INTERFACE LEVEL
Architecture independent level 1 (DDI/DKI). PARAMETERS
mp Pointer to the map structure. size Number of units being freed. index Index of the first unit of the allocated resource. DESCRIPTION
rmfree() releases space back into a resource map. It is the opposite of rmalloc(9F), which allocates space that is controlled by a resource map structure. When releasing resources using rmfree() the size and index passed to rmfree() must exactly match the size and index values passed to and returned from a previous call to rmalloc(). Resources cannot be returned piecemeal. Drivers may define resource maps for resource allocation, in terms of arbitrary units, using the rmallocmap(9F) function. The system main- tains the resource map structure by size and index, computed in units appropriate for the resource. For example, units may be byte addresses, pages of memory, or blocks. rmfree() frees up unallocated space for re-use. rmfree() can also be used to initialize a resource map, in which case the size and index should cover the entire resource area. CONTEXT
rmfree() can be called from user or interrupt context. SEE ALSO
rmalloc(9F), rmalloc_wait(9F), rmallocmap(9F), rmfreemap(9F) Writing Device Drivers SunOS 5.10 4 Jun 2001 rmfree(9F)
All times are GMT -4. The time now is 08:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy