[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  Programming
. -> [Folder]  General
. . -> [Subject]  Self-managed hashed strings

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Self-managed hashed strings
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please).
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Pages: 1  2 3  4  

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Mon 20 Mar 2006 04:15 AM (UTC)  quote  ]
Message
Version 0.9.f is released. It includes implementation of the < operator, in addition to some more documentation.

I removed the distinction between str and str_const, in favor of only using the constant version. There isn't really any reason to have a method that returns a copy; if you need a copy you can grab the reference and copy that.

On the web page I note some future plans:
http://david.the-haleys.org/index.php?page=shared-str

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Samson   USA  (683 posts)  [Biography] bio
Date Wed 15 Mar 2006 12:26 PM (UTC)  quote  ]
Message
I'm still planning to make use of this code, I just haven't had the time to do anything with it yet. It looks like it should do exactly what I want though.

I can forsee that adding substr, find, and replace methods would be a huge help if that's at all possible. I have several spots in the code where that would be useful since I'm already using std::string for those now.

SmaugMuds.org: http://www.smaugmuds.org - The Smaug MUDs Community Center

"The past was erased, the erasure was forgotten, the lie became truth." -- George Orwell, 1984
[Go to top] top

Posted by Nick Cash   USA  (626 posts)  [Biography] bio
Date Wed 15 Mar 2006 07:00 AM (UTC)  quote  ]
Message
My base is built from Scratch and doesnt really employ the library to its full extent too well, though that will soon change. Thus, I don't really have any problems just yet. I'll be sure to report back once the base perks up and objects/mobs start making more of an appearance.

Installation was nice and easy, especially since you provided an example program. The only problem I had was due to my own stupidity (I had forgotten I had an older version of the include files laying around...).

For the things I was doing, though rather brief, the + and += methods, along with str() and c_str(), handled everything I needed. A few more methods that the std::string class employs might be useful (substr, etc.) as well, though I doubt it would really be needed.

The documentation was very helpful. I wasn't quite sure what I could and could not do, and it until I read the documentation. It, along with the example program, made it very clear.

Overall it seemed very clear, and everything worked very easily. Definitely one of the best libraries I've delt with in recent times.

~Nick Cash
http://www.nick-cash.com
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Wed 15 Mar 2006 05:11 AM (UTC)  quote  ]
Message
Great! Did you have any problems? How is it going for you?

I finished mine as well. It was a horribly tedious process removing the STRALLOCs etc. but I feel much safer now that the majority of them are gone. (I did keep a few just because I was tired of changing everything.) I think it's using about another megabyte of memory, but I'm not entirely sure and it's hard to take exact measurements. I imagine this is due to the overhead of the hash table, but it's a little more than I expected. I'll have to check out the implementation of the buckets and see if I can't come up with something more efficient. (My first implementation was just something "quick and dirty" to make sure that it worked.)

Most important to me would be feedback on the interface of the shared string. Do you find yourself wanting more methods to the underlying string? (e.g. substr, etc.) I found that generally it worked out quite well for me, once I added the +, += and < operators. (I needed < to store the shared_strs in a map.)

Also, is the documentation good? Any places where it wasn't clear, and/or could be better?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Nick Cash   USA  (626 posts)  [Biography] bio
Date Wed 15 Mar 2006 03:53 AM (UTC)  quote  ]
Message
Your library is now fully integrated with my mud. :)

~Nick Cash
http://www.nick-cash.com
[Go to top] top

Posted by Nick Cash   USA  (626 posts)  [Biography] bio
Date Sun 05 Mar 2006 03:14 AM (UTC)  quote  ]
Message
Quote:
Has anybody tried integrating this into a MUD yet?


I do plan to use it in my base. It is just hard to find time to play with it much while school is winding down to spring break.

~Nick Cash
http://www.nick-cash.com
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Sun 05 Mar 2006 02:08 AM (UTC)  quote  ]

Amended on Sun 05 Mar 2006 02:09 AM (UTC) by David Haley

Message
Yes, it's a shared-string manager. It makes sure that you only have one instance of every string in memory. And it's completely automatic -- no need to worry about STRALLOC and STRFREE vs. DISPOSE, str_dup, etc.

It's not quite a complete substitute for std::string -- it has a few common methods that I've needed but hardly all. That being said, you can call shared_str.str() to get a const std::string& for whatever you'd need to do.

The documentation, while not stellar, isn't too bad -- hopefully it should help explain what's going on and how to use it.

I'm almost done with a near-complete switchover in my code base from old to new string management. I'll have some memory statistics shortly. I'm not expecting much of a memory gain, but you never know. And I have no way of easily measuring CPU use, so I won't bother with that.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Samson   USA  (683 posts)  [Biography] bio
Date Sun 05 Mar 2006 01:53 AM (UTC)  quote  ]
Message
Now, just to refresh my memory, this code of yours handles the same kind of string counting as the hashstr.c stuff in Smaug, right? And it's also a substitute for having to use std::string in C++ STL?

SmaugMuds.org: http://www.smaugmuds.org - The Smaug MUDs Community Center

"The past was erased, the erasure was forgotten, the lie became truth." -- George Orwell, 1984
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Sat 04 Mar 2006 12:02 PM (UTC)  quote  ]
Message
Oh, I also provide an implementation of stricmp if you don't have one already. Make sure you check the documentation for how to use it.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Sat 04 Mar 2006 11:32 AM (UTC)  quote  ]
Message
As I've been integrating this into my MUD, I've found a number of things were missing. As a result I added the += and + operators.

Download version 0.9e:
http://david.the-haleys.org/downloads/shared-string-0.9.e.tgz

I doubt my implementations are the most efficient -- I just needed something to work for me to finish sticking this into my MUD.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Thu 02 Mar 2006 03:20 PM (UTC)  quote  ]
Message
I've released 0.9d of the library. The only new functionality it adds over 0.9c is a new, smarter hash function for the hash table manager. It also adds some documentation.

http://david.the-haleys.org/index.php?page=shared-str

Download:
http://david.the-haleys.org/downloads/shared-string-0.9.d.tgz

Has anybody tried integrating this into a MUD yet? It worked well for me and I'm curious to hear what other people have found.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Enderandrew   USA  (37 posts)  [Biography] bio
Date Fri 17 Feb 2006 01:05 PM (UTC)  quote  ]
Message
For those instances when you need IE to access a page (it requires ActiveX like Windows Update, for instance) you can use a browser called Maxthon.

It offers the IE rendering engine, ActiveX, tabbed browsing, and most of the security features of Firefox. It also allows plugins/extensions/themes like Firefox.

For pages where you don't want ActiveX, you can block it. It some ways, it is actually BETTER than Firefox.

"Nihilism makes me smile."
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Thu 16 Feb 2006 03:58 AM (UTC)  quote  ]
Message
Yeah, I've had funky problems downloading with IE as well. That's why I haven't used IE for anything other than Windows Update for over two years. :-)

I'm glad your compile worked fine. I discovered that I use the function stricmp which seems to be non-standard, and it didn't compile out-of-the-box on one of the systems I installed it on. Fortunately, stricmp is very easy to reimplement.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Nick Cash   USA  (626 posts)  [Biography] bio
Date Thu 16 Feb 2006 03:37 AM (UTC)  quote  ]

Amended on Thu 16 Feb 2006 03:47 AM (UTC) by Nick Cash

Message
Most curious. It seems that downloading with IE produces rather dubious results. I downloaded with no problems using Firefox.

Yet another reason to use Firefox! :P

--
On another note, I compiled both under unix and win32 with absolutely zero problems. That is something of a rarity these days. Good work :)

~Nick Cash
http://www.nick-cash.com
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Thu 16 Feb 2006 03:28 AM (UTC)  quote  ]
Message
Are you using the link:
http://david.the-haleys.org/downloads/shared-string-0.9.c.tgz

I just tried it, and I had no problems at all.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


13,266 views.

This is page 2, subject is 4 pages long:  [Previous page]  1  2 3  4  [Next page]

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]