Dear experts,
I am new to c++ (arriving from java) and I am having to implement a
data table that contains cells with numbers and cells with text. I
would appreciate any general indications about what would be the best
approach, bearing in mind that performance will be critical.
Many thanks
Johan 6 1970
Johan wrote: I am new to c++ (arriving from java) and I am having to implement a data table that contains cells with numbers and cells with text. I would appreciate any general indications about what would be the best approach, bearing in mind that performance will be critical.
Using std::vector<std ::vector<std::s tring> > seems the most straight-
forward. If you know the dimensions of the "table" ahead of its
creation, you could use a simple two-dimensional array of std::string.
Since you didn't say what you're going to do with the table or its
cells, "performanc e will be critical" has no meaning. Perhaps if you
state the requirements, as in "performanc e to resize" or "performanc e
to replace data" or "performanc e to search"...
V
"Johan" wrote Dear experts,
I am new to c++ (arriving from java) and I am having to implement a data table that contains cells with numbers and cells with text. I would appreciate any general indications about what would be the best approach, bearing in mind that performance will be critical.
It depends on your requirements (ie. whether dupes ok or not, auto-sorted or not etc.).
But basically you define what a cell item is and then make an array of it.
You can also use std::vector, std::set, std::list, std::map, std::multimap etc. etc.
Uenal Mutlu wrote: "Johan" wrote Dear experts,
I am new to c++ (arriving from java) and I am having to implement a data table that contains cells with numbers and cells with text. I would appreciate any general indications about what would be the
best approach, bearing in mind that performance will be critical. It depends on your requirements (ie. whether dupes ok or not,
auto-sorted or not etc.). But basically you define what a cell item is and then make an array
of it. You can also use std::vector, std::set, std::list, std::map,
std::multimap etc. etc.
THanks for your answers.
A bit of info about what I need to implement. The size of the table
will be unknown until runtime. The table will be fairly big (a few
thousands of cells) and will contain both numbers and text strings at
the same time. Numbers will have to remain as such in order to do
maths with them.
Once the table has been acquired, regrouping of cells will be done: 1
cell from every 2x2, with a content (text of number) calculated through
certain algorithms on the 4 grouped cells. Then further groupings: 1
cell with every 4x4, 8x8...). The original table needs to be preserved
and change of views will be done, forth and back, responding to user
actions, in real time.
Many thanks for any further comments on how to implement this
J
<jo*********@gm ail.com> wrote THanks for your answers.
A bit of info about what I need to implement. The size of the table will be unknown until runtime.
But when it is known is it then constant?
The table will be fairly big (a few thousands of cells) and will contain both numbers and text strings at the same time. Numbers will have to remain as such in order to do maths with them. Once the table has been acquired, regrouping of cells will be done: 1 cell from every 2x2, with a content (text of number) calculated through certain algorithms on the 4 grouped cells. Then further groupings: 1 cell with every 4x4, 8x8...). The original table needs to be preserved and change of views will be done, forth and back, responding to user actions, in real time.
Many thanks for any further comments on how to implement this
From C++ point of view this is basic stuff.
I don't know what types your cell contains (ie. is it an integer or floating point
number, and can the string be arbitrarily long or is there a max length),
but you have multiple ways to chose from. The simplest but maybe not
that mighty would be something like:
struct Cell
{
int iVal;
char szStr[64];
};
Cell* paCell = new Cell[nCells];
where nCells is the number of cells to allocate dynamically.
This is a 1-dimensional array of Cells; you can also make it n-dimensional.
Here you must delete the resource when finished by using
delete [] paCell;
On the other hand, depending on the class used, STL does the allocation
either in the constructor or when a new item gets added, and frees the
resource(s) in its destructor.
You just need to specify your application requirements as complete
as possible, but this is of course obvious for any language used.
I personally would recommend to use STL classes.
"Johan" <jo*********@gm ail.com> wrote in message
news:63******** *************** ***@posting.goo gle.com... Dear experts,
I am new to c++ (arriving from java) and I am having to implement a data table that contains cells with numbers and cells with text. I would appreciate any general indications about what would be the best approach, bearing in mind that performance will be critical.
Many thanks
Johan
When you talk about "cells", are you just talking conceptually, or do you
mean some kind of graphical display, like you see in spreadsheet programs?
The standard C++ language does not provide graphical support (GUI, mouse,
etc.), if that's what you're ultimately looking for. For that you need a
third-party library (like MFC in Visual C++, for example). But if all you
want is the storage method, then something like std::vector (or one of the
other containers) might be appropriate. Which one depends on the type of
operations you need to do (sorting, inserts, deletes, etc.) (Or, perhaps
you're interested in a real database, such as SQL or Access? In that case,
you'd again need to go to some third-party software.)
-Howard This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Michael Lauzon |
last post by:
This is not for a class, I have a group on SourceForge, this is what
one of the Developers is asking; the more advanced you can make it
right off all the better!:
Can someone please create some MySQL to create the first table: the
players table.
It will need to include (as a minimum):
- ID (unique)
|
by: Andrew Thompson |
last post by:
http://www.physci.org/test/chem/element.html,
represents information on a chemical element.
(http://www.physci.org/test/chem/ for the CSS's)
Not yet coded for links to other forms of
the element. Suggestions for layout welcome.
NN 4.8 displays lambda, kappa and rho as '?'.
Is there any way of getting the greek letters
to appear for NN 4.8?
|
by: WindAndWaves |
last post by:
Hi Gurus
I was wondering if you can send me in the right direction:
I have a table with about 300 rows. I want to make all of them invisible
and when a user enters a code in a form then make selected ones visible.
At the moment, I am doing it as follows:
www.corstorphinehouse.com/d/avail.html
|
by: Kim14 |
last post by:
I have a table that works fine in IE, but doesn't work in Netscape or
Firefox. It should automatically come up with numbers in some of the
fields and depending what is entered, it should calculate and come up
with a dollar amount.
If anyone out there sees what I am doing wrong- could you offer some
advice? I apologize in advance for adding the entire code- I know it
is more than most of you are willing to look at, but I just can't...
|
by: Yeah |
last post by:
Hi, all! I have a question.
I am designing a listing similar to a phone book in HTML. Each listing has
periods following it, but they must extend to the end of the table cell, and
not wrap.
Is there any way to prevent the text from 1) wrapping within the table cell
and 2) causing the table cell to expand? In other words, the filler periods
must flow past the right boundary of the cell (but not be seen). Similar to:
| |
by: Bob |
last post by:
Hi all,
I've got a table that I've imported and it has junk at the top of the
table, so after import I run a delete query to remove the junk lines
then I'm left with the field names I want for the table at the top of
the table but the field names currently are 'field1' etc, so how do I
rename the field names to the fields on the top row of the table.
Cheers,
|
by: Stubert |
last post by:
I have a training module db that stores information about employees
and what training they have carried our or need to carry out. One
table in this database stores what training needs to be carried based
on a job title. So if a cleaner joins the company we know that they
need the sweeping up training and the mopping up training. I wasn't
sure how to store this information but this is what i came up with and
as you will see i have hit a...
|
by: Lucas_london via AccessMonster.com |
last post by:
Hi
I have set up a database/tables in Access based on daily timeseries data.
However I would like to create two additional columns in the table as a basis
to pull the data on a weekly and monthly series basis.
Currently, in excel I am using the weekday and EOMONTH functions to create
the flags/indicator in my excel dataset:
(Cells in column A contains daily dates)
|
by: pranav13 |
last post by:
hi all,
im pranav. i have a table with checkbox, sno, book name, book price as coloumns in it. Everything is 5ne while adding and deleting rows.
But my requirement is that, now i want to update the checkbox IDs and row numbers.
For example, pretend that there are 5 rows in the table. I have deleted 2nd and 4th. Now, it should make the 3rd row as 2nd row by updating the checkbox id and sno as chk2 and 2 resp.
here is my code.
<!DOCTYPE...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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...
| |