473,783 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1445
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::s tring, int> indices_of_size s_by_user;
std::map<std::s tring, int> indices_of_size s_by_directory;
std::vector<lon g> sizes;
public:
void adduser(std::st ring const&);
void adddirectory(st d::string const&);
long sumbyuser(std:: string const&) const;
long sumbydirectory( std::string const&) const;
long size(std::strin g 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::s tring, std::map<std::s tring,int> >
indices_of_size s_by_user;
std::map<std::s tring, std::map<std::s tring,int> >
indices_of_size s_by_directory;
std::vector<lon g> sizes;
public:
void adduser(std::st ring const&);
void adddirectory(st d::string const&);
long sumbyuser(std:: string const&) const;
long sumbydirectory( std::string const&) const;
long size(std::strin g const& user, std::string const& dir) const;
void addsize(std::st ring const& user, std::string const& dir, long);
};

The 'indices_of_siz es_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_siz es_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.l earn.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.programmin g] 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.programmin g]

--
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.programmin g] 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.programmin g]


--
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.MultiInde x 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.MultiInde x 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.MultiInde x, 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.MultiInde x, 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
2580
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 program for the internet, but don't know where to get all of my information from to be the most knowledgeable I can be. Do i find what i'm looking for in some class somewhere? if so where do i look? or do i just buy all the asp, php, xml, etc...
1
1851
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. Everything starts with a simple template class like the one below. In this example class A has two template parameters but that number can be different. template < typename T, typename U > class A
4
1519
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 abstract so I'm looking at the source code (c++) to this wrapper and dll. For those interested the full source code is here:
4
1842
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 just starting to convert to VB.NET). Most of my database backends are SQL Server 2000 with a few still Access. I want to educate myself so that I can code (and understand) processes like reading an XML file and adding the contained information to...
3
1842
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 to Implementation. Likewise, Implementation has a reference to Interface, but not to Client. Interface contains a class that I want to be constructed by some class+method in Implementation, and nowhere else.
5
1452
by: marcosegurini | last post by:
Hi, the following class describes my actual problem: class DeepCopy<T> { T val_; public void Assign(T newVal) {
13
3115
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 sorts of clients. Mine are all small businesses whose sites will never reach those sorts of scales. I deal with businesses whose sites get maybe a few hundred visitors per day (some not even that much) and get no more than ten orders per day....
4
1624
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 Graph(object): ... It seems that their Graph is subclassed from "object" but I couldn't find a "object" class anywhere. So, I abandoned using that one.
11
2352
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 method dynamically to match the arguments supplied to it when it is defined. For example... public delegate void MyDelegate(string myString, int myInt);
12
2409
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 available in Mountain View, CA.
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10147
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9946
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.