473,804 Members | 3,196 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1408
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
4379
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 returndata. So 0 fits into a short so I have to convert to a short, although I say that my stored procedure has to return a NUMBER(16), thus int. Can anyone tell me how I can determine my return datatype beforehand?
8
1954
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 extra thing to. The datatype is a class I made. Is there anyway for me to test a parameters datatype in a template using function?
0
1689
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 the Clone() method. Before I add the new DataTable to the DataSet, I change the DataType of a DataColumn from System.String to System.Int64. I then add data to the new table and then add it to the DataSet. Then DataSet is then added to the Cache....
2
2908
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" use="required"/> Notice the use="required" attribute...
3
3345
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 currency data type in asp.net and the type is idenfied as decimal. I have two fields defined in Sql-Server, one is money and other is decimal. In asp.net both are identified as decimal.
3
5333
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 xsd:date element called XYZ_IncDate. <xsd:attribute name="XYZ_IncDate" type="xsd:date" use="required"> If I change the xsd:date element to be optional, then wsdl.exe generates two attributes for the date field in the proxy class:
4
11972
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? Thanks for your help!!
2
1244
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
1891
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 quite as robust on Windows as it is in other environments. Here's what I'm finding:
1
7781
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 the proxy class of webservice and makes a synchronous call to webservice GetReport() op. Here is the code snippet - *************************************************************************************** wbFELIP.wsZProcessReport.ProcessReport...
0
9579
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,...
1
10321
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10077
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...
1
7620
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
6853
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
5522
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...
1
4300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3820
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2991
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.