July 22, 2002
anderson wrote:

> What type of numbers does ClassInfo return? Will the algorithm need a hash table?

D provides associative arrays built-in.  You don't have to worry about the internals; Walter does that for you!

--
The Villagers are Online! http://villagersonline.com

.[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ]
.[ (a version.of(English).(precise.more)) is(possible) ]
?[ you want.to(help(develop(it))) ]


July 22, 2002
Oh, I get that. Thanks.

"Russ Lewis" <spamhole-2001-07-16@deming-os.org> wrote in message news:3D3BF7FB.6C9C809A@deming-os.org...
> anderson wrote:
>
> > What type of numbers does ClassInfo return? Will the algorithm need a
hash
> > table?
>
> D provides associative arrays built-in.  You don't have to worry about the internals; Walter does that for you!
>
> --
> The Villagers are Online! http://villagersonline.com
>
> .[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ]
> .[ (a version.of(English).(precise.more)) is(possible) ]
> ?[ you want.to(help(develop(it))) ]
>
>


July 22, 2002
"anderson" <anderson@firestar.com.au> wrote in message news:ahgls0$130b$1@digitaldaemon.com...
>
> "Pavel Minayev" <evilone@omen.ru> wrote in message
> news:CFN374589713982292@news.digitalmars.com...
> On Sun, 21 Jul 2002 09:36:30 -0700 "Sean L. Palmer"
> <seanpalmer@earthlink.net>
> wrote:
>
> > Sure it does.  Just replace getType() with int(&classinfo(*this)) or
> > something similar.
>
> > Better yet, use an associative array:
>
> > int[ClassInfo] countSelected;
>
> > Then, no need for getType(). Just use .classinfo of object.
>
>
> Which leads me to my point.
>
> So to call,
>
> "
>     int getTotalSelectedOfType()
>     {
          return countSelected[this.classinfo()];
>     }
> "
>
> I'd have to be virutal and static right?
>
> Otherwise I'd have to have an existing object to call it. Also doesn't
this
> denote the need for an object? I'd like to quarie the class.
>
>


July 22, 2002
"Sean L. Palmer" <seanpalmer@earthlink.net> wrote in message news:ah8k4f$1oop$1@digitaldaemon.com...
> Lines are not Vertices.  Polygons are not Triangles.
>
> You should be using HasA, not IsA relationships.

Your right! I was thinking of anther project where we used a static machine
for with 4 states/modes:
Vertex, edge, polygon and object. The idea was that the same operations
(translate, scale, rotate, ect...) could be applied to groups of objects in
differn't modes. Yes, getNumbSelected was one of them and could be used to
get the total amount of vertexes, edges, polygons and objects. If in vertex
mode it would return the number of vertexes for a single object. If in
object mode it would return 1 if the object was selected.

But that's besides the point. isA (I perfer java style here) should be
applied to boolean types.


July 22, 2002
On Mon, 22 Jul 2002 18:04:08 +0800 "anderson" <anderson@firestar.com.au> wrote:

> What type of numbers does ClassInfo return? Will the algorithm need a hash table?

classinfo property is not a number, it's a reference to ClassInfo object. But there's nothing wrong in using object references as hashtable keys. =)
July 22, 2002
On Mon, 22 Jul 2002 18:19:01 +0800 "anderson" <anderson@firestar.com.au> wrote:

> Which leads me to my point.
> 
> So to call,
> 
> "
>     int getTotalSelectedOfType()
>     {
>         return countSelected(this.classinfo());
>     }
> "
> 
> I'd have to be virutal and static right?
> 
> Otherwise I'd have to have an existing object to call it. Also doesn't this denote the need for an object? I'd like to quarie the class.

You can. Just let it take a classinfo as an argument:

	static int getTotalSelectedOfType(ClassInfo ci)
	{
		return countSelected[ci];
	}

And then:

	getTotalSelectedOfType(Vertex.classinfo);

July 23, 2002
Thanks. Cool, you could never do that in C++.

CountSelected becomes practicly a VT anyway. I still think think things would have been simpler with virtual statics but this is close enough I suppose.

//With virtual statics

class GeometricPrimitive
{
private:
    static virtual int countSelected;
    bool selected;
public:
    void setSelected()
    {
        selected = true;
        countSelected.length++;
    }
    bool isSelected()
    {
        return selected;
    }
    static virtual int getNumbSelected()
    {
        return countSelected;
    }
}

No need for arrays or anything, and it makes more sense.

> You can. Just let it take a classinfo as an argument:

> static int getTotalSelectedOfType(ClassInfo ci)
> {
> return countSelected[ci];
> }

> And then:

> getTotalSelectedOfType(Vertex.classinfo);



July 23, 2002
Whoops, forgot to remove the length++

"anderson" <anderson@firestar.com.au> wrote in message news:ahia9e$2p7u$1@digitaldaemon.com...
> Thanks. Cool, you could never do that in C++.
>
> CountSelected becomes practicly a VT anyway. I still think think things would have been simpler with virtual statics but this is close enough I suppose.
>
> //With virtual statics
>
> class GeometricPrimitive
> {
> private:
>     static virtual int countSelected;
>     bool selected;
> public:
>     void setSelected()
>     {
>         selected = true;
          countSelected++;
>     }
>     bool isSelected()
>     {
>         return selected;
>     }
>     static virtual int getNumbSelected()
>     {
>         return countSelected;
>     }
> }
>
> No need for arrays or anything, and it makes more sense.
>
> > You can. Just let it take a classinfo as an argument:
>
> > static int getTotalSelectedOfType(ClassInfo ci)
> > {
> > return countSelected[ci];
> > }
>
> > And then:
>
> > getTotalSelectedOfType(Vertex.classinfo);
>
>
>


July 23, 2002
On Tue, 23 Jul 2002 09:13:43 +0800 "anderson" <anderson@firestar.com.au> wrote:

> Thanks. Cool, you could never do that in C++.

Why? You can have map<type_info*, int>, and use typeid() operator.

July 24, 2002
"Pavel Minayev" <evilone@omen.ru> wrote in message news:CFN374606405046875@news.digitalmars.com...
> On Tue, 23 Jul 2002 09:13:43 +0800 "anderson" <anderson@firestar.com.au>
wrote:
>
> > Thanks. Cool, you could never do that in C++.
>
> Why? You can have map<type_info*, int>, and use typeid() operator.

I should have rephrased that to "how could you do that in C++".  Thanks.