dev-cpp-users Mailing List for Dev-C++ (Page 388)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
You can subscribe to this list here.
| 2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(15) |
Oct
(115) |
Nov
(154) |
Dec
(258) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2001 |
Jan
(377) |
Feb
(260) |
Mar
(249) |
Apr
(188) |
May
(152) |
Jun
(150) |
Jul
(195) |
Aug
(202) |
Sep
(200) |
Oct
(286) |
Nov
(242) |
Dec
(165) |
| 2002 |
Jan
(245) |
Feb
(241) |
Mar
(239) |
Apr
(346) |
May
(406) |
Jun
(369) |
Jul
(418) |
Aug
(357) |
Sep
(362) |
Oct
(597) |
Nov
(455) |
Dec
(344) |
| 2003 |
Jan
(446) |
Feb
(397) |
Mar
(515) |
Apr
(524) |
May
(377) |
Jun
(387) |
Jul
(532) |
Aug
(364) |
Sep
(294) |
Oct
(352) |
Nov
(295) |
Dec
(327) |
| 2004 |
Jan
(416) |
Feb
(318) |
Mar
(324) |
Apr
(249) |
May
(259) |
Jun
(218) |
Jul
(212) |
Aug
(259) |
Sep
(158) |
Oct
(162) |
Nov
(214) |
Dec
(169) |
| 2005 |
Jan
(111) |
Feb
(165) |
Mar
(199) |
Apr
(147) |
May
(131) |
Jun
(163) |
Jul
(235) |
Aug
(136) |
Sep
(84) |
Oct
(88) |
Nov
(113) |
Dec
(100) |
| 2006 |
Jan
(85) |
Feb
(119) |
Mar
(33) |
Apr
(31) |
May
(56) |
Jun
(68) |
Jul
(18) |
Aug
(62) |
Sep
(33) |
Oct
(55) |
Nov
(19) |
Dec
(40) |
| 2007 |
Jan
(22) |
Feb
(49) |
Mar
(34) |
Apr
(51) |
May
(66) |
Jun
(43) |
Jul
(116) |
Aug
(57) |
Sep
(70) |
Oct
(69) |
Nov
(97) |
Dec
(86) |
| 2008 |
Jan
(32) |
Feb
(47) |
Mar
(106) |
Apr
(67) |
May
(28) |
Jun
(39) |
Jul
(31) |
Aug
(25) |
Sep
(18) |
Oct
(25) |
Nov
(5) |
Dec
(21) |
| 2009 |
Jan
(33) |
Feb
(27) |
Mar
(27) |
Apr
(22) |
May
(22) |
Jun
(10) |
Jul
(17) |
Aug
(9) |
Sep
(21) |
Oct
(13) |
Nov
(4) |
Dec
(11) |
| 2010 |
Jan
(10) |
Feb
(8) |
Mar
(4) |
Apr
(1) |
May
|
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(8) |
Oct
(26) |
Nov
(9) |
Dec
(1) |
| 2011 |
Jan
(21) |
Feb
(16) |
Mar
(4) |
Apr
(19) |
May
(26) |
Jun
(9) |
Jul
(6) |
Aug
|
Sep
(4) |
Oct
(3) |
Nov
(2) |
Dec
(1) |
| 2012 |
Jan
(4) |
Feb
(7) |
Mar
(4) |
Apr
|
May
(1) |
Jun
(10) |
Jul
(1) |
Aug
(1) |
Sep
(18) |
Oct
(3) |
Nov
(1) |
Dec
(1) |
| 2013 |
Jan
(4) |
Feb
(2) |
Mar
(15) |
Apr
(6) |
May
(1) |
Jun
(3) |
Jul
(1) |
Aug
(2) |
Sep
(4) |
Oct
|
Nov
(9) |
Dec
|
| 2014 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(5) |
Aug
(4) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
(4) |
| 2015 |
Jan
(2) |
Feb
(3) |
Mar
(1) |
Apr
(2) |
May
(1) |
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(2) |
Oct
(9) |
Nov
(35) |
Dec
(6) |
| 2016 |
Jan
(7) |
Feb
(10) |
Mar
(10) |
Apr
(9) |
May
(13) |
Jun
(9) |
Jul
(1) |
Aug
(3) |
Sep
(3) |
Oct
(1) |
Nov
(1) |
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
(1) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Lists <li...@dr...> - 2003-05-03 04:20:53
|
Hello, I've taken a break from programming and now that I'm getting back into = it I want to make sure I do it right, with the right equipment. Can = anyone tell me the benefit of using Dev-C++ over the Borland compiler I = used in the past? Tvienti |
|
From: David M. <dem...@uw...> - 2003-05-03 01:44:38
|
Uint16 isn't an SDL type. It's a type that's in <stdarg.h> I belive, a typedef for a value that will be exactly 16 bytes. Same with Uint32, etc. At 10:23 AM 02/05/2003 -0400, David Matthews wrote: >Hi! > >For Dev-C++ 4.9.8.0 I downloaded the SDL package, which works well with >the functions (I can initialize the video susbsystem for ex.), but when I >want to use a type, like Uint16, the compiler doesn't understand it. SDL.h >is included. > > Thanks, > > Laszlo > > > >------------------------------------------------------- >This sf.net email is sponsored by:ThinkGeek >Welcome to geek heaven. >http://thinkgeek.com/sf >_______________________________________________ >Dev-cpp-users mailing list >Dev...@li... >TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > |
|
From: Ioannis V. <iv...@em...> - 2003-05-02 22:55:42
|
If I want to add staand alone images on a form (not part of a toolbar or something), is there some control specific for that or I have to use GDI only? Regards, Ioannis Vranos * Programming pages: http://www.noicys.freeurl.com * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net |
|
From: Szathmary L. <sz...@de...> - 2003-05-02 12:20:28
|
Hi! For Dev-C++ 4.9.8.0 I downloaded the SDL package, which works well with the functions (I can initialize the video susbsystem for ex.), but when I want to use a type, like Uint16, the compiler doesn't understand it. SDL.h is included. Thanks, Laszlo |
|
From: Ricardo R. <ri...@un...> - 2003-05-02 10:31:21
|
you dont need to swap the both matrices, you can easily switch from one matrix to the other with a pointer, as follows: ************************************** int matrix1 [ N ] [ M ]; int matrix2[N][M]; int *q = matrix1[0]; matrix1[1][0]=8; cout << matrix1[1][0] << *(q+3); q = matrix2[0]; matrix2[1][0]=9; cout << matrix2[1][0] << *(q+3); ******************************** |
|
From: Ricardo R. <ri...@un...> - 2003-05-02 10:23:31
|
It seems that you can find an alternative solution,
for instance in your case:
***************************
#define N 2
#define M 3
int main()
{
int matrix [ N ] [ M ];
int *q = matrix[0];
matrix[1][0]=8;
cout << matrix[1][0] << *(q+3);
system("PAUSE");
return 0;
}
**************************
|
|
From: Dany P. W. <da...@qu...> - 2003-05-02 04:51:01
|
Hi everyone, I've just reached the part about error handling and I'm afraid it had me thoroughly confuzzled! Here's a simple bit of code which, at the very end, requires a float input. How can I catch mistakes made by entering the wrong type of data, e.g. character where it should be numeric or visa versa? ==================================================== cin.ignore (1); cout << "\nName of Dish: "; getline (cin,sName); cout << "Description: "; getline (cin,sDescription); cout << "Price? "; cin >> fPrice; ==================================================== Any help would be immensely appreciated. I seem to learn better by simple examples. Cheers, D. -- This mail is a natural product. The slight variations in spelling and grammar enhance its individual character and beauty and in no way are to be considered flaws or defects. |
|
From: Ioannis V. <iv...@at...> - 2003-05-02 03:32:52
|
> -----Original Message----- > From: dev...@li...=20 > [mailto:dev...@li...] On Behalf=20 > Of David McKen > Sent: Thursday, May 01, 2003 10:09 PM > To: dev...@li... > Subject: Re: [Dev-C++] 'extern const' and std::vector >=20 >=20 > The rooms are not nesesarily accessed in sequential order. > One very used > command (at least by admins) is the goto command. Syntax: > goto <vnum or > player>. This can cause an admin in room #300 to need > access to room #50000. > Also ceartain other command allow ordinary players to make > different jumps > to rooms that are not in sequential order. >=20 > The assiging of rooms to the admins in charge of building > makes it very > likely that the rooms adjacent to the current room are > going to be within > that range (+ or -100) therefore with some exceptions > (which are not that > rare) moving from one room to another involves moving up or > down a few > vnums. As Per Westermark said a map seems to be more suitable than vector since = you are going to add things in the middle and you want random access. Or a multimap I would say if every room is beside in more than one rooms. >=20 > Hmm, I understand about the making the global variable a > class and actually > that was my other question. (I guarantee you if it dosen't > have to e global > I don't want it to be global, that only increases the > number of validity > checks I have to make, eww) >=20 > Each client is going to be in their own thread. For the > reading functions > this should prove no problem (two threads reading the same > variable doesn't > cause any problems? Right?) The writing functions (only > avalible to admins) > are what will require locking down (Mutex, Critical > Section, etc.). Yes you need a locking mechanism (although I do not know much about = threads yet). =20 > One of my original thoughts was to create a vector of > pointers to each room > structure. Thereby allowing random room access and also > allowing the > numbering system to remain intact. >=20 > if the vector currently only has rooms 1-100 filled in and > an admin request > to goto room #150 to start creating a new area then the > rooms in between 100 > and 150 will be NULL pointers that can be checked for, Or in the case of a map only the existing rooms will exist and when accessing a non-existent room, 0 is returned (if suitable for the type, which is suitable for pointers). > if > an admin request a > room the does not exist then a template room is created for > the admin to > edit to their liking. This has the obvious disadvantage in > that if an admin > request room #999999 and the vector only has the rooms up > to #1000 there > will be alot of NULL pointers wasting memory.=20 Yes, so map is perfect, it will not create 0-value pointers (NULL is = better for C, 0 is better for C++ regarding pointers). >Given the way > that these > numbers are assigned this should not be a problem (with the > exception of the > top admins who can load and save any area) most admins are > forced to remain > within their assigned range. >=20 > Any thoughts on this will be appreciated. As Per said: use map (or multimap if it fits you better). > BTW we have a project on sourceforge 'SinstradMUD'. > The current codebase is in the cvs repository in the /src > directory. > The (extremly alpha, still deciding what library to use) > code for the new > codebase is in the Sinstrad2 directory For what OS is it going to be? Ioannis Vranos =20 * Programming pages: http://www.noicys.freeurl.com * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net |
|
From: Per W. <pw...@ia...> - 2003-05-01 19:34:53
|
I would suggest the use of a map template. The access to a room is fast,
and you need not fill each element, i.e. it's ok with large gaps in the
number series.
One more thing. To keep code simple and allow easy change of it. Don't
allow all code to know how you store and retrieve rooms. Let them call
through a function or object method. Then it is easy to later change to
some other storage mechanism - in-memory or on disk. Just require each
player to have an address token (which might be an integer) to their room,
and let each room have a number of address tokens to neighbour rooms. If
you have a teleporter, it stores the address of the destination room.
One problem with multiple threads. Yes, multiple threads may read the same
variable. However, if someone else updates that variable, you're in for
some serious problems. You really should lock the rooms while updating
them, and deny all read operations while the room is locked.
I assume that you will not allow too many concurrent players. 10000
threads is no good. Even 1000 threads is generally bad. Must each player
run it's own script or what? Normally you might have a single thread
handle a large number of players by just round-robin the work. A player
that haven't sent in a command need not be reevaluated unless a timer has
reached zero - or someone else is attacking the poor sod.
/Per W
On Thu, 1 May 2003, David McKen wrote:
> The rooms are not nesesarily accessed in sequential order.
> One very used
> command (at least by admins) is the goto command. Syntax:
> goto <vnum or
> player>. This can cause an admin in room #300 to need
> access to room #50000.
> Also ceartain other command allow ordinary players to make
> different jumps
> to rooms that are not in sequential order.
>
> The assiging of rooms to the admins in charge of building
> makes it very
> likely that the rooms adjacent to the current room are
> going to be within
> that range (+ or -100) therefore with some exceptions
> (which are not that
> rare) moving from one room to another involves moving up or
> down a few
> vnums.
>
> Hmm, I understand about the making the global variable a
> class and actually
> that was my other question. (I guarantee you if it dosen't
> have to e global
> I don't want it to be global, that only increases the
> number of validity
> checks I have to make, eww)
>
> Each client is going to be in their own thread. For the
> reading functions
> this should prove no problem (two threads reading the same
> variable doesn't
> cause any problems? Right?) The writing functions (only
> avalible to admins)
> are what will require locking down (Mutex, Critical
> Section, etc.).
>
> One of my original thoughts was to create a vector of
> pointers to each room
> structure. Thereby allowing random room access and also
> allowing the
> numbering system to remain intact.
>
> if the vector currently only has rooms 1-100 filled in and
> an admin request
> to goto room #150 to start creating a new area then the
> rooms in between 100
> and 150 will be NULL pointers that can be checked for, if
> an admin request a
> room the does not exist then a template room is created for
> the admin to
> edit to their liking. This has the obvious disadvantage in
> that if an admin
> request room #999999 and the vector only has the rooms up
> to #1000 there
> will be alot of NULL pointers wasting memory. Given the way
> that these
> numbers are assigned this should not be a problem (with the
> exception of the
> top admins who can load and save any area) most admins are
> forced to remain
> within their assigned range.
>
> Any thoughts on this will be appreciated.
>
> BTW we have a project on sourceforge 'SinstradMUD'.
> The current codebase is in the cvs repository in the /src
> directory.
> The (extremly alpha, still deciding what library to use)
> code for the new
> codebase is in the Sinstrad2 directory
>
> ----- Original Message -----
> From: "Per Westermark" <pw...@ia...>
> To: "David McKen" <ci...@ya...>
> Cc: <dev...@li...>
> Sent: Thursday, May 01, 2003 2:11 PM
> Subject: Re: [Dev-C++] 'extern const' and std::vector
>
>
> > It still sounds like an object-oriented construct would
> work.
> >
> > Make all data protected.
> >
> > Add a lot of nice access functions.
> >
> > Create one function that returns a const room entry. Any
> user of the room
> > may then only call const methods.
> >
> > Give the administrators some way of retrieving a
> non-const room entry.
> >
> > class Room;
> >
> > class xx {
> > public:
> > const Room& GetRoom(RoomId& id);
> > Room& GetRoom(RoomId& id,const char
> *admin_password);
> > };
> >
> > However, I still don't think that you need access to a
> room in constant
> > time. Logaritmic time would probably produce the
> reference to the room in
> > a fraction of the time that the work code need to perform
> actions on the
> > room - presenting contents of room, check for monsters or
> other players in
> > the room, ...
> >
> > There are a number of disadvantages to using a vector,
> unless the data is
> > absolutely static. It takes a lot of time O(n) to insert
> a new entry in
> > the middle. If new entries are not inserted last, all
> existing indices -
> > and probably also pointers to them - will be invalidated.
> >
> > /Per W
> >
> > On Thu, 1 May 2003, David McKen wrote:
> >
> > > Random access is essential!!!!
> > >
> > > We are storing them sequentially and the system for
> access
> > > uses the fact
> > > that room #3001 is located just after room #3000 (helps
> > > with speed).
> > > Concerning the comment that this is a bad design. This
> > > vector is what needs
> > > to be global. Only ceartain players (the admins) have
> the
> > > ability to
> > > directly edit this room data (this will also be
> > > controlled). No matter what
> > > part of the MMORPG is being used it will need access to
> > > this information
> > > (only some basic information commands don't).
> > >
> > > ----- Original Message -----
> > > From: "Ioannis Vranos" <iv...@at...>
> > > To: "Dev-C++ Mailing List"
> > > <dev...@li...>
> > > Sent: Thursday, May 01, 2003 1:27 PM
> > > Subject: RE: [Dev-C++] 'extern const' and std::vector
> > >
> > >
> > > > > -----Original Message-----
> > > > > From: Per Westermark [mailto:pw...@ia...]
> > > > > Sent: Thursday, May 01, 2003 8:23 PM
> > > > > To: Ioannis Vranos
> > > > > Cc: dev...@li...
> > > > > Subject: RE: [Dev-C++] 'extern const' and
> std::vector
> > > > >
> > > > >
> > > > > I assume MMORPG is Massive Multiplayer Online
> > > Role-Playing Game.
> > > > >
> > > > > If the game isn't too boring, I'm also assuming
> that
> > > you don't walk
> > > > > through the rooms in a sequential order.
> > > > >
> > > > > If you need random access, I would really go for a
> tree
> > > > > construct. Each
> > > > > node might point zero more alternative rooms, while
> you
> > > would still be
> > > > > able to locate a room in O(log n) time.
> > > > >
> > > > > If the tree for some reason gets too large to keep
> in
> > > memory, it might
> > > > > easily be placed partially on disk.
> > > >
> > > >
> > > >
> > > > I do not know much about trees but how can one have
> > > random access in a
> > > tree?
> > > > Trees involve sequential comparisons, don't they?
> > > >
> > > >
> > > >
> > > >
> > > > Ioannis Vranos
> > > >
> > > > * Programming pages: http://www.noicys.freeurl.com
> > > > * Alternative URL 1: http://run.to/noicys
> > > > * Alternative URL 2: http://www.noicys.cjb.net
> > > >
> > > >
> > > >
> > > >
> > > >
> -------------------------------------------------------
> > > > This sf.net email is sponsored by:ThinkGeek
> > > > Welcome to geek heaven.
> > > > http://thinkgeek.com/sf
> > > > _______________________________________________
> > > > Dev-cpp-users mailing list
> > > > Dev...@li...
> > > > TO UNSUBSCRIBE:
> http://www.noicys.cjb.net/devcpp/ub.htm
> > > >
> > >
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
> > >
> > >
> > > __________________________________
> > > Do you Yahoo!?
> > > The New Yahoo! Search - Faster. Easier. Bingo.
> > > http://search.yahoo.com
> > >
> > >
> > > -------------------------------------------------------
> > > This sf.net email is sponsored by:ThinkGeek
> > > Welcome to geek heaven.
> > > http://thinkgeek.com/sf
> > > _______________________________________________
> > > Dev-cpp-users mailing list
> > > Dev...@li...
> > > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> > >
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
> > >
> >
>
>
> __________________________________
> Do you Yahoo!?
> The New Yahoo! Search - Faster. Easier. Bingo.
> http://search.yahoo.com
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|
|
From: David M. <ci...@ya...> - 2003-05-01 19:09:23
|
The rooms are not nesesarily accessed in sequential order.
One very used
command (at least by admins) is the goto command. Syntax:
goto <vnum or
player>. This can cause an admin in room #300 to need
access to room #50000.
Also ceartain other command allow ordinary players to make
different jumps
to rooms that are not in sequential order.
The assiging of rooms to the admins in charge of building
makes it very
likely that the rooms adjacent to the current room are
going to be within
that range (+ or -100) therefore with some exceptions
(which are not that
rare) moving from one room to another involves moving up or
down a few
vnums.
Hmm, I understand about the making the global variable a
class and actually
that was my other question. (I guarantee you if it dosen't
have to e global
I don't want it to be global, that only increases the
number of validity
checks I have to make, eww)
Each client is going to be in their own thread. For the
reading functions
this should prove no problem (two threads reading the same
variable doesn't
cause any problems? Right?) The writing functions (only
avalible to admins)
are what will require locking down (Mutex, Critical
Section, etc.).
One of my original thoughts was to create a vector of
pointers to each room
structure. Thereby allowing random room access and also
allowing the
numbering system to remain intact.
if the vector currently only has rooms 1-100 filled in and
an admin request
to goto room #150 to start creating a new area then the
rooms in between 100
and 150 will be NULL pointers that can be checked for, if
an admin request a
room the does not exist then a template room is created for
the admin to
edit to their liking. This has the obvious disadvantage in
that if an admin
request room #999999 and the vector only has the rooms up
to #1000 there
will be alot of NULL pointers wasting memory. Given the way
that these
numbers are assigned this should not be a problem (with the
exception of the
top admins who can load and save any area) most admins are
forced to remain
within their assigned range.
Any thoughts on this will be appreciated.
BTW we have a project on sourceforge 'SinstradMUD'.
The current codebase is in the cvs repository in the /src
directory.
The (extremly alpha, still deciding what library to use)
code for the new
codebase is in the Sinstrad2 directory
----- Original Message -----
From: "Per Westermark" <pw...@ia...>
To: "David McKen" <ci...@ya...>
Cc: <dev...@li...>
Sent: Thursday, May 01, 2003 2:11 PM
Subject: Re: [Dev-C++] 'extern const' and std::vector
> It still sounds like an object-oriented construct would
work.
>
> Make all data protected.
>
> Add a lot of nice access functions.
>
> Create one function that returns a const room entry. Any
user of the room
> may then only call const methods.
>
> Give the administrators some way of retrieving a
non-const room entry.
>
> class Room;
>
> class xx {
> public:
> const Room& GetRoom(RoomId& id);
> Room& GetRoom(RoomId& id,const char
*admin_password);
> };
>
> However, I still don't think that you need access to a
room in constant
> time. Logaritmic time would probably produce the
reference to the room in
> a fraction of the time that the work code need to perform
actions on the
> room - presenting contents of room, check for monsters or
other players in
> the room, ...
>
> There are a number of disadvantages to using a vector,
unless the data is
> absolutely static. It takes a lot of time O(n) to insert
a new entry in
> the middle. If new entries are not inserted last, all
existing indices -
> and probably also pointers to them - will be invalidated.
>
> /Per W
>
> On Thu, 1 May 2003, David McKen wrote:
>
> > Random access is essential!!!!
> >
> > We are storing them sequentially and the system for
access
> > uses the fact
> > that room #3001 is located just after room #3000 (helps
> > with speed).
> > Concerning the comment that this is a bad design. This
> > vector is what needs
> > to be global. Only ceartain players (the admins) have
the
> > ability to
> > directly edit this room data (this will also be
> > controlled). No matter what
> > part of the MMORPG is being used it will need access to
> > this information
> > (only some basic information commands don't).
> >
> > ----- Original Message -----
> > From: "Ioannis Vranos" <iv...@at...>
> > To: "Dev-C++ Mailing List"
> > <dev...@li...>
> > Sent: Thursday, May 01, 2003 1:27 PM
> > Subject: RE: [Dev-C++] 'extern const' and std::vector
> >
> >
> > > > -----Original Message-----
> > > > From: Per Westermark [mailto:pw...@ia...]
> > > > Sent: Thursday, May 01, 2003 8:23 PM
> > > > To: Ioannis Vranos
> > > > Cc: dev...@li...
> > > > Subject: RE: [Dev-C++] 'extern const' and
std::vector
> > > >
> > > >
> > > > I assume MMORPG is Massive Multiplayer Online
> > Role-Playing Game.
> > > >
> > > > If the game isn't too boring, I'm also assuming
that
> > you don't walk
> > > > through the rooms in a sequential order.
> > > >
> > > > If you need random access, I would really go for a
tree
> > > > construct. Each
> > > > node might point zero more alternative rooms, while
you
> > would still be
> > > > able to locate a room in O(log n) time.
> > > >
> > > > If the tree for some reason gets too large to keep
in
> > memory, it might
> > > > easily be placed partially on disk.
> > >
> > >
> > >
> > > I do not know much about trees but how can one have
> > random access in a
> > tree?
> > > Trees involve sequential comparisons, don't they?
> > >
> > >
> > >
> > >
> > > Ioannis Vranos
> > >
> > > * Programming pages: http://www.noicys.freeurl.com
> > > * Alternative URL 1: http://run.to/noicys
> > > * Alternative URL 2: http://www.noicys.cjb.net
> > >
> > >
> > >
> > >
> > >
-------------------------------------------------------
> > > This sf.net email is sponsored by:ThinkGeek
> > > Welcome to geek heaven.
> > > http://thinkgeek.com/sf
> > > _______________________________________________
> > > Dev-cpp-users mailing list
> > > Dev...@li...
> > > TO UNSUBSCRIBE:
http://www.noicys.cjb.net/devcpp/ub.htm
> > >
> >
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > The New Yahoo! Search - Faster. Easier. Bingo.
> > http://search.yahoo.com
> >
> >
> > -------------------------------------------------------
> > This sf.net email is sponsored by:ThinkGeek
> > Welcome to geek heaven.
> > http://thinkgeek.com/sf
> > _______________________________________________
> > Dev-cpp-users mailing list
> > Dev...@li...
> > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> >
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
> >
>
__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com
|
|
From: Ioannis V. <iv...@at...> - 2003-05-01 18:20:34
|
Since the rooms are one next the other then you do not need random access
(=after room [1] you may access room [2679]). If you do not need such jumps
then a tree or a list or whatever may be ok too. std::list for example is
great for sorting.
Regarding the vector you can use one in a namespace and access it with an
iterator for parts which can write and const_iterator for the parts who can
only read.
The iterators of vector arre random access iterators, so they entirely
behave as regular pointers. Code that demonstrates vector iterator ability:
#include <vector>
#include <iostream>
namespace hesperia
{
std::vector<int>myvec(200);
}
int main()
{
using namespace std;
using hesperia::myvec;
vector<int>::iterator p=myvec.begin();
for(vector<int>::size_type i=0; i<myvec.size()/2; i++)
p[i]=7;
vector<int>::const_iterator r=myvec.begin();
for(vector<int>::size_type i=0; i<myvec.size()/2; i++)
cout<<r[i]<<" ";
*(p+7)=8;
}
Ioannis Vranos
* Programming pages: http://www.noicys.freeurl.com
* Alternative URL 1: http://run.to/noicys
* Alternative URL 2: http://www.noicys.cjb.net
-----Original Message-----
From: David McKen [mailto:ci...@ya...]
Sent: Thursday, May 01, 2003 8:54 PM
To: Ioannis Vranos
Subject: Re: [Dev-C++] 'extern const' and std::vector
Random access is essential!!!!
We are storing them sequentially and the system for access uses the fact
that room #3001 is located just after room #3000 (helps with speed).
Concerning the comment that this is a bad design. This vector is what needs
to be global. Only ceartain players (the admins) have the ability to
directly edit this room data (this will also be controlled). No matter what
part of the MMORPG is being used it will need access to this information
(only some basic information commands don't).
|
|
From: Per W. <pw...@ia...> - 2003-05-01 18:12:53
|
It still sounds like an object-oriented construct would work.
Make all data protected.
Add a lot of nice access functions.
Create one function that returns a const room entry. Any user of the room
may then only call const methods.
Give the administrators some way of retrieving a non-const room entry.
class Room;
class xx {
public:
const Room& GetRoom(RoomId& id);
Room& GetRoom(RoomId& id,const char *admin_password);
};
However, I still don't think that you need access to a room in constant
time. Logaritmic time would probably produce the reference to the room in
a fraction of the time that the work code need to perform actions on the
room - presenting contents of room, check for monsters or other players in
the room, ...
There are a number of disadvantages to using a vector, unless the data is
absolutely static. It takes a lot of time O(n) to insert a new entry in
the middle. If new entries are not inserted last, all existing indices -
and probably also pointers to them - will be invalidated.
/Per W
On Thu, 1 May 2003, David McKen wrote:
> Random access is essential!!!!
>
> We are storing them sequentially and the system for access
> uses the fact
> that room #3001 is located just after room #3000 (helps
> with speed).
> Concerning the comment that this is a bad design. This
> vector is what needs
> to be global. Only ceartain players (the admins) have the
> ability to
> directly edit this room data (this will also be
> controlled). No matter what
> part of the MMORPG is being used it will need access to
> this information
> (only some basic information commands don't).
>
> ----- Original Message -----
> From: "Ioannis Vranos" <iv...@at...>
> To: "Dev-C++ Mailing List"
> <dev...@li...>
> Sent: Thursday, May 01, 2003 1:27 PM
> Subject: RE: [Dev-C++] 'extern const' and std::vector
>
>
> > > -----Original Message-----
> > > From: Per Westermark [mailto:pw...@ia...]
> > > Sent: Thursday, May 01, 2003 8:23 PM
> > > To: Ioannis Vranos
> > > Cc: dev...@li...
> > > Subject: RE: [Dev-C++] 'extern const' and std::vector
> > >
> > >
> > > I assume MMORPG is Massive Multiplayer Online
> Role-Playing Game.
> > >
> > > If the game isn't too boring, I'm also assuming that
> you don't walk
> > > through the rooms in a sequential order.
> > >
> > > If you need random access, I would really go for a tree
> > > construct. Each
> > > node might point zero more alternative rooms, while you
> would still be
> > > able to locate a room in O(log n) time.
> > >
> > > If the tree for some reason gets too large to keep in
> memory, it might
> > > easily be placed partially on disk.
> >
> >
> >
> > I do not know much about trees but how can one have
> random access in a
> tree?
> > Trees involve sequential comparisons, don't they?
> >
> >
> >
> >
> > Ioannis Vranos
> >
> > * Programming pages: http://www.noicys.freeurl.com
> > * Alternative URL 1: http://run.to/noicys
> > * Alternative URL 2: http://www.noicys.cjb.net
> >
> >
> >
> >
> > -------------------------------------------------------
> > This sf.net email is sponsored by:ThinkGeek
> > Welcome to geek heaven.
> > http://thinkgeek.com/sf
> > _______________________________________________
> > Dev-cpp-users mailing list
> > Dev...@li...
> > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> >
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
>
> __________________________________
> Do you Yahoo!?
> The New Yahoo! Search - Faster. Easier. Bingo.
> http://search.yahoo.com
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|
|
From: Ioannis V. <iv...@at...> - 2003-05-01 18:07:52
|
> -----Original Message----- > From: Per Westermark [mailto:pw...@ia...] > Sent: Thursday, May 01, 2003 8:54 PM > To: Ioannis Vranos > Cc: Dev-C++ Mailing List > Subject: RE: [Dev-C++] 'extern const' and std::vector > > > That's the logaritmic search time. > > If the tree is binary, every step down the tree halves the > alternative, > similar to the bsearch() function available in ISO 9899. > > If the tree is of higher order, i.e. more than two > alternatives at heach > level, it will subdivide the alternatives faster. > > If there are 32 values at each level, each level will do a 2^5 > subdivision. A 6-level tree would hold up to 2^(5*6) entries. > Max 6 tree > nodes to test for locating a single entry among 1 billion > alternatives. Still it is not "random access" (but sounds more O(n)), so implementing an operator[] for it would not be efficient (according with the ideals of C++ regarding [] efficiency). Unless the OP means different things for "random access", that's why I asked him if the search is sequential (=the next room is stored next to the existing room). > Too bad that all insert/remove operations also takes O(log n) > for a total > of O(n*log n) time to populate the tree. But then again, > O(n*log n) is the > expected efficiency for a general sort. > > Check out libredblack at sourceforge. A red-black tree is an > improvement > of the trusty btree, with a built-in hysteresis when a tree > has to grow > with one more level, or shrunk one level. > > Because of the good behaviour, it isn't uncommon that the stl > map template > is implemented with a red-black tree. That's nice. :) Trees are an interesting concept. Ioannis Vranos * Programming pages: http://www.noicys.freeurl.com * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net |
|
From: GWAVA <pos...@Te...> - 2003-05-01 18:00:11
|
This is an automated Notification e-mail message from GWAVA. The message you sent, from the address dev...@li... to [No To Addresses] Concerning: Dev-cpp-users digest, Vol 1 #1439 - 6 msgs Was not delivered because the message was found to be Spam by the e-mail system in use at the intended recipient's organization. If you think this message is not Spam and should have been delivered, or you have any questions concerning this message, please contact the pos...@te... |
|
From: David M. <ci...@ya...> - 2003-05-01 17:56:15
|
Random access is essential!!!! We are storing them sequentially and the system for access uses the fact that room #3001 is located just after room #3000 (helps with speed). Concerning the comment that this is a bad design. This vector is what needs to be global. Only ceartain players (the admins) have the ability to directly edit this room data (this will also be controlled). No matter what part of the MMORPG is being used it will need access to this information (only some basic information commands don't). ----- Original Message ----- From: "Ioannis Vranos" <iv...@at...> To: "Dev-C++ Mailing List" <dev...@li...> Sent: Thursday, May 01, 2003 1:27 PM Subject: RE: [Dev-C++] 'extern const' and std::vector > > -----Original Message----- > > From: Per Westermark [mailto:pw...@ia...] > > Sent: Thursday, May 01, 2003 8:23 PM > > To: Ioannis Vranos > > Cc: dev...@li... > > Subject: RE: [Dev-C++] 'extern const' and std::vector > > > > > > I assume MMORPG is Massive Multiplayer Online Role-Playing Game. > > > > If the game isn't too boring, I'm also assuming that you don't walk > > through the rooms in a sequential order. > > > > If you need random access, I would really go for a tree > > construct. Each > > node might point zero more alternative rooms, while you would still be > > able to locate a room in O(log n) time. > > > > If the tree for some reason gets too large to keep in memory, it might > > easily be placed partially on disk. > > > > I do not know much about trees but how can one have random access in a tree? > Trees involve sequential comparisons, don't they? > > > > > Ioannis Vranos > > * Programming pages: http://www.noicys.freeurl.com > * Alternative URL 1: http://run.to/noicys > * Alternative URL 2: http://www.noicys.cjb.net > > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users __________________________________ Do you Yahoo!? The New Yahoo! Search - Faster. Easier. Bingo. http://search.yahoo.com |
|
From: Per W. <pw...@ia...> - 2003-05-01 17:55:17
|
That's the logaritmic search time. If the tree is binary, every step down the tree halves the alternative, similar to the bsearch() function available in ISO 9899. If the tree is of higher order, i.e. more than two alternatives at heach level, it will subdivide the alternatives faster. If there are 32 values at each level, each level will do a 2^5 subdivision. A 6-level tree would hold up to 2^(5*6) entries. Max 6 tree nodes to test for locating a single entry among 1 billion alternatives. Too bad that all insert/remove operations also takes O(log n) for a total of O(n*log n) time to populate the tree. But then again, O(n*log n) is the expected efficiency for a general sort. Check out libredblack at sourceforge. A red-black tree is an improvement of the trusty btree, with a built-in hysteresis when a tree has to grow with one more level, or shrunk one level. Because of the good behaviour, it isn't uncommon that the stl map template is implemented with a red-black tree. /Per W On Thu, 1 May 2003, Ioannis Vranos wrote: > > -----Original Message----- > > From: Per Westermark [mailto:pw...@ia...] > > Sent: Thursday, May 01, 2003 8:23 PM > > To: Ioannis Vranos > > Cc: dev...@li... > > Subject: RE: [Dev-C++] 'extern const' and std::vector > > > > > > I assume MMORPG is Massive Multiplayer Online Role-Playing Game. > > > > If the game isn't too boring, I'm also assuming that you don't walk > > through the rooms in a sequential order. > > > > If you need random access, I would really go for a tree > > construct. Each > > node might point zero more alternative rooms, while you would still be > > able to locate a room in O(log n) time. > > > > If the tree for some reason gets too large to keep in memory, it might > > easily be placed partially on disk. > > > > I do not know much about trees but how can one have random access in a tree? > Trees involve sequential comparisons, don't they? > > > > > Ioannis Vranos > > * Programming pages: http://www.noicys.freeurl.com > * Alternative URL 1: http://run.to/noicys > * Alternative URL 2: http://www.noicys.cjb.net > > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: Ioannis V. <iv...@at...> - 2003-05-01 17:27:51
|
> -----Original Message----- > From: Per Westermark [mailto:pw...@ia...]=20 > Sent: Thursday, May 01, 2003 8:23 PM > To: Ioannis Vranos > Cc: dev...@li... > Subject: RE: [Dev-C++] 'extern const' and std::vector >=20 >=20 > I assume MMORPG is Massive Multiplayer Online Role-Playing Game. >=20 > If the game isn't too boring, I'm also assuming that you don't walk > through the rooms in a sequential order. >=20 > If you need random access, I would really go for a tree=20 > construct. Each > node might point zero more alternative rooms, while you would still be > able to locate a room in O(log n) time. >=20 > If the tree for some reason gets too large to keep in memory, it might > easily be placed partially on disk. I do not know much about trees but how can one have random access in a = tree? Trees involve sequential comparisons, don't they? Ioannis Vranos =20 * Programming pages: http://www.noicys.freeurl.com * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net |
|
From: Per W. <pw...@ia...> - 2003-05-01 17:24:45
|
I assume MMORPG is Massive Multiplayer Online Role-Playing Game. If the game isn't too boring, I'm also assuming that you don't walk through the rooms in a sequential order. If you need random access, I would really go for a tree construct. Each node might point zero more alternative rooms, while you would still be able to locate a room in O(log n) time. If the tree for some reason gets too large to keep in memory, it might easily be placed partially on disk. /Per W On Thu, 1 May 2003, Ioannis Vranos wrote: > -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf Of David McKen > Sent: Thursday, May 01, 2003 6:22 PM > To: dev...@li... > Subject: Re: [Dev-C++] 'extern const' and std::vector > > > > I think I better explain my current position. > > I am helping create a MMORPG. The vector is going to be used for access to > the rooms. The current room system uses vnums (each rooms is assigned a vnum > which is used to access it, another reason for my choice of vector). exits > to other rooms just refrence the vnum and the code knows exactly what room > to put the user in. > > > The rooms are changing sequencially, that is you do not need random access? > > > Ioannis Vranos > > * Programming pages: <http://www.noicys.freeurl.com/> > http://www.noicys.freeurl.com > * Alternative URL 1: <http://run.to/noicys> http://run.to/noicys > * Alternative URL 2: <http://www.noicys.cjb.net/> http://www.noicys.cjb.net > > > Anti-racism movement: <http://www.positive-youthfoundation.org/> > http://www.positive-youthfoundation.org > Iraq Peace Pledge: <http://www.peacepledge.org/> http://www.peacepledge.org > > |
|
From: Ioannis V. <iv...@at...> - 2003-05-01 16:36:35
|
-----Original Message----- From: dev...@li... [mailto:dev...@li...] On Behalf Of David = McKen Sent: Thursday, May 01, 2003 6:22 PM To: dev...@li... Subject: Re: [Dev-C++] 'extern const' and std::vector I think I better explain my current position. =20 I am helping create a MMORPG. The vector is going to be used for access = to the rooms. The current room system uses vnums (each rooms is assigned a = vnum which is used to access it, another reason for my choice of vector). = exits to other rooms just refrence the vnum and the code knows exactly what = room to put the user in.=20 =20 The rooms are changing sequencially, that is you do not need random = access? =20 =20 Ioannis Vranos * Programming pages: <http://www.noicys.freeurl.com/> http://www.noicys.freeurl.com * Alternative URL 1: <http://run.to/noicys> http://run.to/noicys * Alternative URL 2: <http://www.noicys.cjb.net/> = http://www.noicys.cjb.net Anti-racism movement: <http://www.positive-youthfoundation.org/> http://www.positive-youthfoundation.org Iraq Peace Pledge: <http://www.peacepledge.org/> = http://www.peacepledge.org |
|
From: Ioannis V. <iv...@at...> - 2003-05-01 16:31:31
|
> -----Original Message-----
> From: dev...@li...=20
> [mailto:dev...@li...] On Behalf=20
> Of David McKen
> Sent: Thursday, May 01, 2003 6:22 PM
> To: dev...@li...
> Subject: Re: [Dev-C++] 'extern const' and std::vector
>=20
>=20
> I see.
>=20
> So const extern is out of the question then. No problem
> just need to
> hope these functions don't try to write to the varible.
Why you would need such a global variable in the first place? It really
sounds like a bad design decision. In any case you can do something =
like:
namespace whatever
{
// Your variable
int x;
inline void write(int y) { x=3Dy; }
inline int read() { return x; }
}
or use a class. In any case I can't understand why you need it to be =
global.
>=20
> Actually 2^32 is the upper limit using the current world
> size we have not
> passed 10000 entries. We have some serious expansion in
> mind thus I am
> planning for some of the heaviest loads. The current
> implementation uses a
> doubly-linked list (links point both to the next entry and
> the previous
> entry).
> As you gan guess this can be problematic when the number of
> entries begins
> to really start growing. Thats why I am looking for
> alternatives.
I assume you need random access?
Ioannis Vranos
=20
* Programming pages: http://www.noicys.freeurl.com
* Alternative URL 1: http://run.to/noicys
* Alternative URL 2: http://www.noicys.cjb.net
Anti-racism movement: http://www.positive-youthfoundation.org
Iraq Peace Pledge: http://www.peacepledge.org
|
|
From: Ioannis V. <iv...@at...> - 2003-05-01 16:27:11
|
> -----Original Message----- > From: Per Westermark [mailto:pw...@ia...] > Sent: Thursday, May 01, 2003 6:15 PM > To: Ioannis Vranos > Cc: Dev-C++ Mailing List > Subject: RE: [Dev-C++] 'extern const' and std::vector > > > Yes, this exists: > extern const int x; > > However, that is a constant. The request - as I read it - was > for a global > variable to be const in just one file, while writeable in other files. Ok then I recall. :) It sounds like he is doing a bad design though. > When extern-declaring something (that is already declared > somewhere else), > you should declare it identical to the original declaration, > and it this > case the original declaration is not const. Yes. Ioannis Vranos * Programming pages: http://www.noicys.freeurl.com * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net Anti-racism movement: http://www.positive-youthfoundation.org Iraq Peace Pledge: http://www.peacepledge.org |
|
From: David M. <ci...@ya...> - 2003-05-01 15:21:45
|
MessageI think I better explain my current position. I am helping create a MMORPG. The vector is going to be used for access to the rooms. The current room system uses vnums (each rooms is assigned a vnum which is used to access it, another reason for my choice of vector). exits to other rooms just refrence the vnum and the code knows exactly what room to put the user in. For this reason a sequence container seems to be my only option. The same system is used for the objects and mobiles (characters that are not players). ----- Original Message ----- From: Ioannis Vranos To: dev...@li... Sent: Thursday, May 01, 2003 11:02 AM Subject: RE: [Dev-C++] 'extern const' and std::vector
-----Original Message-----
From: dev...@li... [mailto:dev...@li...] On Behalf Of David McKen
Sent: Thursday, May 01, 2003 4:10 PM
To: dev...@li...
Subject: [Dev-C++] 'extern const' and std::vector
My first question concerns the extern keyword. If I have a varible in one file (it is not a constant) but that varible needs to accessed from the functions in another file. However these other functions do not need (actually I don't want them to have) write access to this variable, can I do something similar to 'const <var_type> <var_name>?'. For those of you who are wondering why I don;t just try it myself I would like to know what EVERY ANSI compatible compiler will do. The program I am writing must remain portable. You do not specify language. That creates extra pain. In C & C++ yes you can do extern const int x; In C++ you have better use a namespace. My other question concerns the std::vector container class of the STD. As far as I have seen the std:vector class stores it's contents contiguously in memory (just like an array). Does this make vector classes reach their maximum size once there is no block of memory big enough to hold it's data? You haven't to worry about these details. It is an implementation worry and in reality the vector is just a handler interface. That's why the vector::swap() works instantly. Also you can specify for it your own memory allocator. But handlers and allocators are advanced magic for me yet so i can't tell you more on that till i end TC++PL3. :) In any case you have not to worry about these details. I plan to use this class to act as the index for world system with up to 2^32 rooms in it (even if I store only pointers to each structure it still gets pretty big). Would any of the other containers be better suited to this purpose? I chose the vector bacause of it's speed (4 billion possible rooms, gonna need the speed). The requirements for the container is to allow for a numbering system for eah of the rooms with rooms being grouped within ranges. Regarding constant random access with [] time cost: vector, deque, string, valarray and bitset have this. Reference for all the time costs for all containers for all types of access ([], front operations, etc): "The C++ Programming Language" 3rd Edition or Special Edition by Bjarne Stroustrup (the creator of C++): On page 464. Ioannis Vranos
* Programming pages: http://www.noicys.freeurlcom
* Alternative URL 1: http://run.to/noicys
* Alternative URL 2: http://www.noicys.cjb.net
Anti-racism movement: http://www.positive-youthfoundation.org
Iraq Peace Pledge: http://www.peacepledge.org
---------------------------------
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo. |
|
From: David M. <ci...@ya...> - 2003-05-01 15:21:41
|
I see. So const extern is out of the question then. No problem just need to hope these functions don't try to write to the varible. Actually 2^32 is the upper limit using the current world size we have not passed 10000 entries. We have some serious expansion in mind thus I am planning for some of the heaviest loads. The current implementation uses a doubly-linked list (links point both to the next entry and the previous entry). As you gan guess this can be problematic when the number of entries begins to really start growing. Thats why I am looking for alternatives. ----- Original Message ----- From: "Per Westermark" <pw...@ia...> To: "David McKen" <ci...@ya...> Cc: <dev...@li...> Sent: Thursday, May 01, 2003 10:23 AM Subject: Re: [Dev-C++] 'extern const' and std::vector I'm not too good at the latest updates of the standards, but to the best of my knowledge, there is no const extern declarations. Extern is just a keyword to inform the compiler that somewhere in another linking unit, the specified variable or function exists. However, you can not just lie, because when you reference the symbol, the compiler will insert a name-mangled reference and the linker will then fail if an exactly identical reference isn't available somewhere in one of the included object or library files. Because c++ uses name-mangling, you can't just change the declaration of a variable in your extern statement. There might be C++ compilers that doesn't change the name-mangling for a const contra non-const variable. In that case, this scheme would work for that compiler. However, I'm pretty sure that you would have to search a lot for a compiler with such a name-mangling. If, on the other hand, you declare the variable as "C", you can do just about anything, i.e. you might declare the variable as char in one source file and as unsigned long in another. Then it's up to you to figure out if the program will survive, or if it will go up in a big explosion when you try and run it. About 2^32 elements in a vector - I hope you are running a 64-bit operating system. Even a vector of 2^32 characters would fill the full address space of a 32-bit processor. Ever wondered about the big need of 64-bit processors and operating systems for large database applications? If I assume that you don't need 2^32 elements, just an address range of 2^32, I would suggest a slower (log n) solution using some form of btree or similar. Then you might traverse down the tree until you find the node containing the range, or no match is found. If you don't have to support ranges, but just want to either find an element, or know that it isn't there, go for a hash solution instead. It will perform insert and lookup operations in constant time. /Per W On Thu, 1 May 2003, David McKen wrote: > My first question concerns the extern keyword. If I have a varible in one file (it is not a constant) but that varible needs to accessed from the functions in another file. However these other functions do not need (actually I don't want them to have) write access to this variable, can I do something similar to 'const <var_type> <var_name>?'. For those of you who are wondering why I don;t just try it myself I would like to know what EVERY ANSI compatible compiler will do. The program I am writing must remain portable. My other question concerns the std::vector container class of the STD. As far as I have seen the std:vector class stores it's contents contiguously in memory (just like an array). Does this make vector classes reach their maximum size once there is no block of memory big enough to hold it's data? I plan to use this class to act as the index for world system with up to 2^32 rooms in it (even if I store only pointers to each structure it still gets pretty big). Would any of the other containers be better suited to this purpose? I chose the vector bacause of it's speed (4 billion possible rooms, gonna need the speed). The requirements for the container is to allow for a numbering system for eah of the rooms with rooms being grouped within ranges. > > --------------------------------- > Do you Yahoo!? > The New Yahoo! Search - Faster. Easier. Bingo. __________________________________ Do you Yahoo!? The New Yahoo! Search - Faster. Easier. Bingo. http://search.yahoo.com |
|
From: Per W. <pw...@ia...> - 2003-05-01 15:16:06
|
Yes, this exists: extern const int x; However, that is a constant. The request - as I read it - was for a global variable to be const in just one file, while writeable in other files. When extern-declaring something (that is already declared somewhere else), you should declare it identical to the original declaration, and it this case the original declaration is not const. /Per W On Thu, 1 May 2003, Ioannis Vranos wrote: > > -----Original Message----- > > From: dev...@li... > > [mailto:dev...@li...] On Behalf > > Of Per Westermark > > Sent: Thursday, May 01, 2003 5:23 PM > > To: David McKen > > Cc: dev...@li... > > Subject: Re: [Dev-C++] 'extern const' and std::vector > > > > > > I'm not too good at the latest updates of the standards, but > > to the best > > of my knowledge, there is no const extern declarations. > > > Why? > > > > > Extern is just a keyword to inform the compiler that > > somewhere in another > > linking unit, the specified variable or function exists. > > However, you can > > not just lie, because when you reference the symbol, the compiler will > > insert a name-mangled reference and the linker will then fail if an > > exactly identical reference isn't available somewhere in one of the > > included object or library files. > > > If you do extern int x; > > > and you do not define x elsewhere, it is considered a definition. The same > applies for > > extern int x=1; > > > It is considered a definition (extern is ignored). > > > > > > Ioannis Vranos > > * Programming pages: http://www.noicys.freeurl.com > * Alternative URL 1: http://run.to/noicys > * Alternative URL 2: http://www.noicys.cjb.net > > > Anti-racism movement: http://www.positive-youthfoundation.org > Iraq Peace Pledge: http://www.peacepledge.org > > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: Ioannis V. <iv...@at...> - 2003-05-01 15:05:30
|
> -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Per Westermark > Sent: Thursday, May 01, 2003 5:23 PM > To: David McKen > Cc: dev...@li... > Subject: Re: [Dev-C++] 'extern const' and std::vector > > > I'm not too good at the latest updates of the standards, but > to the best > of my knowledge, there is no const extern declarations. Why? > Extern is just a keyword to inform the compiler that > somewhere in another > linking unit, the specified variable or function exists. > However, you can > not just lie, because when you reference the symbol, the compiler will > insert a name-mangled reference and the linker will then fail if an > exactly identical reference isn't available somewhere in one of the > included object or library files. If you do extern int x; and you do not define x elsewhere, it is considered a definition. The same applies for extern int x=1; It is considered a definition (extern is ignored). Ioannis Vranos * Programming pages: http://www.noicys.freeurl.com * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net Anti-racism movement: http://www.positive-youthfoundation.org Iraq Peace Pledge: http://www.peacepledge.org |