473,406 Members | 2,312 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,406 software developers and data experts.

Required DataType ???

Hi All,

I have the following setup, and I was wondering what would be the best
data type to achieve it.

I have a class A, that stores a list of type X's and a list of type Y's.
I also have a class B, that stores lists of type X's and type Y's .
Class A also stores a list of class B's call it list L.

Ok so I want to know how best to define type/class/struct of X and Y's
given that class A and B use them, and their job is simply to provide 2
pointers to the elements in the list L (of class B's) contained in Class A.

Adam
Jul 23 '05 #1
3 1396
Adam Hartshorne wrote:
I have the following setup, and I was wondering what would be the best
data type to achieve it.

I have a class A, that stores a list of type X's and a list of type
Y's. I also have a class B, that stores lists of type X's and type
Y's . Class A also stores a list of class B's call it list L.

Ok so I want to know how best to define type/class/struct of X and Y's
given that class A and B use them, and their job is simply to provide
2 pointers to the elements in the list L (of class B's) contained in
Class A.


Instead of describing the relationship between objects in your world,
like "I need to model the traffic with cars and passengers", you try
to describe your chosen implementation "A has a list of X and Y and
B has a list of X and Y". That is not a good way to ask for advice
on a class hierarchy. Why is the job of X and Y objects to provide
pointers to elements of L? Seems like a contrived (read: no basis in
reality) example.

If I translate to C++

struct X;
struct Y;

struct B {
std::list<X> listX;
std::list<Y> listY;
};

struct A {
std::list<X> listX;
std::list<Y> listY;
std::list<B> listL;
};

struct X {
B *pointer;
};

struct Y {
B *pointer;
};

So, this actually satisfies the requirements as stated (and they also
contain the ambiguity of whether X and Y should contain 2 pointers each
or one pointer each, and I went with the latter). But I bet you will
not be able to use it. So, again, what is the _problem_ you're trying
to solve?

To define a type means to define its interface. The interface is the
set of public members (usually functions). The functionality must come
from the way the class is to be *used*, not from what data is stores.
As soon as you realise that, all your modeling obstacles will disappear
and you will sail freely toward your goals.

Do not approach solving your problem from the wrong end. Data member
(like a list of X or B in your objects) description is actually secondary
to the class design, which is secondary to your modeling objectives.
Helping with data members cannot be successfully done without knowing
the other two parts of the process.

V
Jul 23 '05 #2
Victor Bazarov wrote:
Adam Hartshorne wrote:
I have the following setup, and I was wondering what would be the best
data type to achieve it.

I have a class A, that stores a list of type X's and a list of type
Y's. I also have a class B, that stores lists of type X's and type
Y's . Class A also stores a list of class B's call it list L.

Ok so I want to know how best to define type/class/struct of X and Y's
given that class A and B use them, and their job is simply to provide
2 pointers to the elements in the list L (of class B's) contained in
Class A.

Instead of describing the relationship between objects in your world,
like "I need to model the traffic with cars and passengers", you try
to describe your chosen implementation "A has a list of X and Y and
B has a list of X and Y". That is not a good way to ask for advice
on a class hierarchy. Why is the job of X and Y objects to provide
pointers to elements of L? Seems like a contrived (read: no basis in
reality) example.

If I translate to C++

struct X;
struct Y;

struct B {
std::list<X> listX;
std::list<Y> listY;
};

struct A {
std::list<X> listX;
std::list<Y> listY;
std::list<B> listL;
};

struct X {
B *pointer;
};

struct Y {
B *pointer;
};

So, this actually satisfies the requirements as stated (and they also
contain the ambiguity of whether X and Y should contain 2 pointers each
or one pointer each, and I went with the latter). But I bet you will
not be able to use it. So, again, what is the _problem_ you're trying
to solve?

To define a type means to define its interface. The interface is the
set of public members (usually functions). The functionality must come
from the way the class is to be *used*, not from what data is stores.
As soon as you realise that, all your modeling obstacles will disappear
and you will sail freely toward your goals.

Do not approach solving your problem from the wrong end. Data member
(like a list of X or B in your objects) description is actually secondary
to the class design, which is secondary to your modeling objectives.
Helping with data members cannot be successfully done without knowing
the other two parts of the process.

V

Ok without going into too mamy specifics which I am not allowed to
reveal, I will try to state the problem with more detail.

I am setting up a markov random field. I have a class for the whole MRF
system (Class A), and a class to model a site in the MRF (Class B). Ok,
so Class A contains a list of ClassB's.

Well MRF don't operate on the sites alone, they operate on cliques
(groups of MRF sites) of different magnitude (say 1 site/2 sites/ 3sites).

I have stored the complete lists of each of the types of cliques in
Class A, call them L1,L2,L3. Also, each MRF site (Class B) must have
knowledge of which cliques they are involved in. So each MRF Site (Class
B) must itself have a list (for each type of clique) of pointers to the
elements in the complete lists (L1,L2,L3) stored in Class A.

Well I am concerned with how to form the data structure for each type of
cliques, given that they really only provide pointers to sets of
RmfSites, and must be accessible to the instance of Class A and
instances of ClassB.

Basically do I want a class/struct or something completely different? in
a seperate file to both Class A and ClassB etc or somehow stored in say
Class A but still accessible to ClassB. In fact do I actually want
ClassB and the clique structs as a classes/structs defined inside ClassA?

Adam
Jul 23 '05 #3
Adam Hartshorne wrote:
[...]
I am setting up a markov random field. I have a class for the whole
MRF system (Class A), and a class to model a site in the MRF (Class
B). Ok, so Class A contains a list of ClassB's.

Well MRF don't operate on the sites alone, they operate on cliques
(groups of MRF sites) of different magnitude (say 1 site/2 sites/
3sites).
I have stored the complete lists of each of the types of cliques in
Class A, call them L1,L2,L3. Also, each MRF site (Class B) must have
knowledge of which cliques they are involved in. So each MRF Site
(Class B) must itself have a list (for each type of clique) of
pointers to the elements in the complete lists (L1,L2,L3) stored in
Class A.
Well I am concerned with how to form the data structure for each type
of cliques, given that they really only provide pointers to sets of
RmfSites, and must be accessible to the instance of Class A and
instances of ClassB.

Basically do I want a class/struct or something completely different?
in a seperate file to both Class A and ClassB etc or somehow stored
in say Class A but still accessible to ClassB. In fact do I actually
want ClassB and the clique structs as a classes/structs defined inside
ClassA?


It so seems that what you need is not a list of cliques in each of A
or B objects, but a list of pointers to cliques or of smart pointers
or even reference-counting pointers to cliques.

I cannot claim any understanding of MRF and related mechanisms, so
your saying "a markov random field", "cliques", falls on dear ears,
I am afraid. Therefore, without your description of how your classes
or the objects are _used_, I cannot advise you much.

V
Jul 23 '05 #4

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

Similar topics

1
by: thepercival | last post by:
Hello, I have a stored procedure and the return data type is number(16) as you can see. but I get it back in the code as a var_numeric and then the precision depends on the value of the...
8
by: Eternally | last post by:
Hi folks, I've got a program which has a function which uses templates to accept parameters of any type. Works well, but there's one certain datatype which I want to special case and do an...
0
by: SoYouKnowBrig | last post by:
Hi All, I am using Microsoft.ApplicationBlocks.Cache.CacheManager to persist a System.Data.Dataset object. This Dataset object has a DataTable that is created from an existing DataTable using...
2
by: Peter McEvoy | last post by:
Hi all, I wonder has anyone seen this behaviour with XsdObjGen tool, and if so, how did you get around it? I have the following in a schema file: <xs:attribute name="sid" type="xs:long"...
3
by: Sri | last post by:
In VB, to know the field type of a column stored in a recordset the command I use is If rsQuery.Fields(k).Type = adCurrency Then How will I achieve the same in ASP.net. I could not find a...
3
by: CindyRob | last post by:
I am using .NET framework 1.1 SP1, .NET framework SDK 1.1 SP1, with hotfix 82202, Visual studio .NET 2003 with hotfix 823639. I have generated a proxy class using wsdl.exe from a schema that has an...
4
by: Orchid | last post by:
How can I change a Date datatype to a Number datatype? For example, I want a date 10/31/2006 to show 1031 as Number datatype. But I don't want it becomes 39021. What formula should I use? ...
2
by: Daniel | last post by:
Is any .net updated required for the new daylight savigns time, or just update the OS is all that is needed? Do DateTime objects need to be updated in .net runtime?
11
by: BD | last post by:
Hi, all. I'm running 8.2 on Windows. This is a development platform for a project whose production environment is running on a mainframe. I believe that the RI compilation process is not...
1
by: santoshsri | last post by:
Hi All, My C# web application calls a webservice to process a report. It sends XMLs as parameter and in response gets an XML node which stores Binay datatype bin.base64. It makes an instance of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
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,...
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
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...

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.