473,396 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Looking for a C++ class.

I need a class that is essentially a matrix (template) class.
I need to be able add rows and columns as needed.
any one know of such a class?

Jul 22 '05 #1
9 1400
JustSomeGuy wrote:
I need a class that is essentially a matrix (template) class.
I need to be able add rows and columns as needed.
any one know of such a class?


Yes, I know of a matrix class (or two, or three). What do you mean
"add rows and columns as needed"?

V
Jul 22 '05 #2
Victor Bazarov wrote:
JustSomeGuy wrote:
I need a class that is essentially a matrix (template) class.
I need to be able add rows and columns as needed.
any one know of such a class?

adding
Yes, I know of a matrix class (or two, or three). What do you mean
"add rows and columns as needed"?


Imaging a table with each row being a directory and each column being a
user name.
As I traverse the file system and find new directories i will be adding
rows to the Matrix.
As i traverse each file within the directory I will be getting the user
name of the person who
owns the file. As new owners are found a column is added to the
Matrix. Each entry in
the Matrix is a sum of the disk space used by that user.

Make sense?

Jul 22 '05 #3
JustSomeGuy wrote:
Victor Bazarov wrote:

JustSomeGuy wrote:
I need a class that is essentially a matrix (template) class.
I need to be able add rows and columns as needed.
any one know of such a class?


adding
Yes, I know of a matrix class (or two, or three). What do you mean
"add rows and columns as needed"?

Imaging a table with each row being a directory and each column being a
user name.
As I traverse the file system and find new directories i will be adding
rows to the Matrix.
As i traverse each file within the directory I will be getting the user
name of the person who
owns the file. As new owners are found a column is added to the
Matrix. Each entry in
the Matrix is a sum of the disk space used by that user.

Make sense?


So, you essentially need an expandable table. It seems that you need some
kind of associative container that has users as keys and directories as
keys as well. The value is the "used space size". I don't think there is
one ready to use. You should roll your own. Shouldn't be that difficult.

class mytable {
std::map<std::string, int> indices_of_sizes_by_user;
std::map<std::string, int> indices_of_sizes_by_directory;
std::vector<long> sizes;
public:
void adduser(std::string const&);
void adddirectory(std::string const&);
long sumbyuser(std::string const&) const;
long sumbydirectory(std::string const&) const;
long size(std::string const& user, std::string const& dir) const;
};

Just start writing...

V
Jul 22 '05 #4
JustSomeGuy wrote:
Victor Bazarov wrote:

JustSomeGuy wrote:
I need a class that is essentially a matrix (template) class.
I need to be able add rows and columns as needed.
any one know of such a class?


adding
Yes, I know of a matrix class (or two, or three). What do you mean
"add rows and columns as needed"?

Imaging a table with each row being a directory and each column being a
user name.
As I traverse the file system and find new directories i will be adding
rows to the Matrix.
As i traverse each file within the directory I will be getting the user
name of the person who
owns the file. As new owners are found a column is added to the
Matrix. Each entry in
the Matrix is a sum of the disk space used by that user.

Make sense?


So, you essentially need an expandable table. It seems that you need some
kind of associative container that has users as keys and directories as
keys as well. The value is the "used space size". I don't think there is
one ready to use. You should roll your own. Shouldn't be that difficult.

class mytable {
std::map<std::string, std::map<std::string,int> >
indices_of_sizes_by_user;
std::map<std::string, std::map<std::string,int> >
indices_of_sizes_by_directory;
std::vector<long> sizes;
public:
void adduser(std::string const&);
void adddirectory(std::string const&);
long sumbyuser(std::string const&) const;
long sumbydirectory(std::string const&) const;
long size(std::string const& user, std::string const& dir) const;
void addsize(std::string const& user, std::string const& dir, long);
};

The 'indices_of_sizes_by_user' contains the user name as the primary key
and the directory name as the secondary key. The value is the index of
the size of the space used by that user in that directory.

The 'indices_of_sizes_by_directory' is a symmetrical table of indices, but
now the primary key is the directory. You don't really need it, only for
sorting purposes since it is going to essentially duplicate the data in
the first one.

The 'sizes' vector is the actual storage of sizes, indexed by the values
from the map[s].

To make sure your 'mytable' class works correctly, remember to add to the
respective maps and to the vector every time you introduce another user or
another directory. The proposed scheme allows you not to keep zero sizes.

Just start implementing it, you'll have fun, trust me...

V
Jul 22 '05 #5
JustSomeGuy wrote:
Victor Bazarov wrote:

JustSomeGuy wrote:
I need a class that is essentially a matrix (template) class.
I need to be able add rows and columns as needed.
any one know of such a class?


adding
Yes, I know of a matrix class (or two, or three). What do you mean
"add rows and columns as needed"?

Imaging a table with each row being a directory and each column being a
user name.
As I traverse the file system and find new directories i will be adding
rows to the Matrix.
As i traverse each file within the directory I will be getting the user
name of the person who
owns the file. As new owners are found a column is added to the
Matrix. Each entry in
the Matrix is a sum of the disk space used by that user.

Make sense?


Search the web for matrix or grid classes.
--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library

Jul 22 '05 #6
* JustSomeGuy:

Imaging a table with each row being a directory and each column being a
user name.
As I traverse the file system and find new directories i will be adding
rows to the Matrix.
As i traverse each file within the directory I will be getting the user
name of the person who
owns the file. As new owners are found a column is added to the
Matrix. Each entry in
the Matrix is a sum of the disk space used by that user.

Make sense?


Yes, but it's not a C++ question (it's off-topic in clc++).

Therefore I've cross-posted to [comp.programming] and set follow-up to
there.

The structure in your data is very classic and very simple,

username 1 <---> n sizeitem n <---> 1 directory

What you need at an abstract relational data base level:

Table Usernames row:
[usename (key), sizeitemID (ref)]

Table Directories row:
[directory (key), sizeitemID (ref)]

Table SizeItems row:
[sizeitemID (key), sizeitem, username (ref), directory (ref)]

Now go implement in C++... ;-)
XFUT: [comp.programming]

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #7
* Alf P. Steinbach:
* JustSomeGuy:

Imaging a table with each row being a directory and each column being a
user name.
As I traverse the file system and find new directories i will be adding
rows to the Matrix.
As i traverse each file within the directory I will be getting the user
name of the person who
owns the file. As new owners are found a column is added to the
Matrix. Each entry in
the Matrix is a sum of the disk space used by that user.

Make sense?
Yes, but it's not a C++ question (it's off-topic in clc++).

Therefore I've cross-posted to [comp.programming] and set follow-up to
there.

The structure in your data is very classic and very simple,

username 1 <---> n sizeitem n <---> 1 directory

What you need at an abstract relational data base level:

Table Usernames row:
[usename (key), sizeitemID (ref)]

Table Directories row:
[directory (key), sizeitemID (ref)]

Table SizeItems row:
[sizeitemID (key), sizeitem, username (ref), directory (ref)]


Bah, posting in haste. Remove the sizeitemID from the first two
tables.

Now go implement in C++... ;-)

XFUT: [comp.programming]


--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #8
JustSomeGuy wrote:
Imaging a table with each row being a directory and each column being
a user name.
As I traverse the file system and find new directories i will be
adding rows to the Matrix.
As i traverse each file within the directory I will be getting the
user name of the person who
owns the file. As new owners are found a column is added to the
Matrix. Each entry in
the Matrix is a sum of the disk space used by that user.

Make sense?


Sound like the Boost.MultiIndex library might be appropriate (I can't say for
sure, since I haven't studied it):

http://www.boost.org/libs/multi_index/doc/index.html

Jonathan
Jul 22 '05 #9
Jonathan Turkanis wrote:
Sound like the Boost.MultiIndex library might be appropriate (I
can't say for sure, since I haven't studied it):

http://www.boost.org/libs/multi_index/doc/index.html


I agree. I just spent a day evaluating Boost.MultiIndex, and it seems
suitable to replace an entire "relations" library I wrote a year ago,
to build many-to-many and many-to-one relations by composing sets of
sets.

I won't know for sure until I attempt replacing my library with
Boost.MultiIndex, but in general it looks great, and I recommend
keeping it in mind as an alternative anytime composing containers of
containers comes up.

--
Dave O'Hearn

Jul 22 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Jason Daly | last post by:
I'm a freshman at college as a computer science major. I'm not sure it has what I want. Does anyone know if a major commonly exists in web design (focusing in server side languages)? I want to...
1
by: Istvan Buki | last post by:
Dear C++ gurus, I'm having some problems inserting some template classes into containers. I'm looking for ideas, suggestions,... on how to achieve this but first let me explain my problem....
4
by: vidalsasoon | last post by:
In Visual Studio I use object viewer to look at a .NET wrapped dll. One class has this signature: public abstract class Slider : ODE.Joints.Joint I don't think the "Slider" class should be...
4
by: Wayne Wengert | last post by:
I am looking for pointers to good beginner books, tutorials or other resources to help me understand how to really use XML data. I program mostly in VB (I have several applications in VB6 but am...
3
by: Brad Quinn | last post by:
Friday, no brain power remains... I have three assemblies; Client, Interface and Implementation. The Client uses Implementation through remoting. Client has a reference to Interface, but not...
5
by: marcosegurini | last post by:
Hi, the following class describes my actual problem: class DeepCopy<T> { T val_; public void Assign(T newVal) {
13
by: Alan Silver | last post by:
Hello, MSDN (amongst other places) is full of helpful advice on ways to do data access, but they all seem geared to wards enterprise applications. Maybe I'm in a minority, but I don't have those...
4
by: John Henry | last post by:
I am looking for a ready made simple graph package. I found an extensive one in the piana package but when I try to use just the graph portion, it fails to load because of the line: class...
11
by: matsi.inc | last post by:
I am looking to make something like a delegate that i can use in my projects but am having a hard time getting started. The behavior I am most interested in is how a delegate changes it's Invoke...
12
by: amogan | last post by:
**If interested & qualified, please reply with your resume directly to amogan@google.com** Referrals are always welcome!! Network System Test Engineer - Mountain View This position is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.