Raised This Month: $ Target: $400
 0% 

Read data from file and later on search throu that data


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Jack86
Veteran Member
Join Date: Dec 2008
Location: Belgrade, Serbia
Old 02-01-2010 , 21:50   Read data from file and later on search throu that data
Reply With Quote #1

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 ?
__________________


Last edited by Jack86; 02-01-2010 at 21:56.
Jack86 is offline
01101101
BANNED
Join Date: Nov 2009
Location: 9`su 09`n0n7e`r0f76a
Old 02-01-2010 , 22:34   Re: Read data from file and later on search throu that data
Reply With Quote #2

You should read a bit about Tries (quim explained about them)
01101101 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-01-2010 , 22:43   Re: Read data from file and later on search throu that data
Reply With Quote #3

Quote:
Originally Posted by Jack86 View Post
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])

__________________
fysiks is offline
Jack86
Veteran Member
Join Date: Dec 2008
Location: Belgrade, Serbia
Old 02-02-2010 , 07:37   Re: Read data from file and later on search throu that data
Reply With Quote #4

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.
__________________

Jack86 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-02-2010 , 21:16   Re: Read data from file and later on search throu that data
Reply With Quote #5

Quote:
Originally Posted by Jack86 View Post
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 View Post
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.
__________________
fysiks is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-02-2010 , 21:56   Re: Read data from file and later on search throu that data
Reply With Quote #6

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?
__________________
Bugsy is offline
Jack86
Veteran Member
Join Date: Dec 2008
Location: Belgrade, Serbia
Old 02-03-2010 , 04:07   Re: Read data from file and later on search throu that data
Reply With Quote #7

I write down in a file several steam id's (around 10) to log some stuff when they are on server.
__________________

Jack86 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-03-2010 , 09:00   Re: Read data from file and later on search throu that data
Reply With Quote #8

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.
__________________
Bugsy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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