AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Read data from file and later on search throu that data (https://forums.alliedmods.net/showthread.php?t=117513)

Jack86 02-01-2010 21:50

Read data from file and later on search throu that data
 
How could i efficiently store bunch of strings from a file and later compare all of them one by one with another string until i find a match ?

Also if first char in string matches with my char, how can a read rest of the string without the first one ?

01101101 02-01-2010 22:34

Re: Read data from file and later on search throu that data
 
You should read a bit about Tries (quim explained about them)

fysiks 02-01-2010 22:43

Re: Read data from file and later on search throu that data
 
Quote:

Originally Posted by Jack86 (Post 1075662)
Also if first char in string matches with my char, how can a read rest of the string without the first one ?

PHP Code:

if( szString[0] == 'a' )
{
    
client_print(id"%s"szString[1])



Jack86 02-02-2010 07:37

Re: Read data from file and later on search throu that data
 
Tnx fysiks. I did read about tries, but as i as seem to understand it, it saves data in pairs by key and value, and i only need to save certain values and seach them.

fysiks 02-02-2010 21:16

Re: Read data from file and later on search throu that data
 
Quote:

Originally Posted by Jack86 (Post 1075662)
How could i efficiently store bunch of strings from a file and later compare all of them one by one with another string until i find a match ?

Quote:

Originally Posted by Jack86 (Post 1076010)
I did read about tries, but as i as seem to understand it, it saves data in pairs by key and value, and i only need to save certain values and seach them.

It really depends on what you do with the the "found" match. If you just need to know if the string is in the list Tries are great. There are other great ways they can be used also.

Bugsy 02-02-2010 21:56

Re: Read data from file and later on search throu that data
 
How large will this list of strings be/get? How long are each of the strings, is there a max? How is this file of strings created? by the same plugin? notepad? another plugin?

Jack86 02-03-2010 04:07

Re: Read data from file and later on search throu that data
 
I write down in a file several steam id's (around 10) to log some stuff when they are on server.

Bugsy 02-03-2010 09:00

Re: Read data from file and later on search throu that data
 
Since you are only storing a handful of steam-id's then I would read the file at plugin_init and cache all the steam id's in an array. If the file changes during run-time you can read directly from the file.


All times are GMT -4. The time now is 07:25.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.