Raised This Month: $ Target: $400
 0% 

Add menu item only if it hasn't been add before


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FEELiFE
Member
Join Date: Jul 2010
Old 05-07-2011 , 08:26   Add menu item only if it hasn't been add before
Reply With Quote #1

Hey guys .

I have a .ini file. I parse the lines, and add a menu items. But I want where it duplicates not to add, and just skip it. Any ideas?

Last edited by FEELiFE; 05-07-2011 at 08:38.
FEELiFE is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 05-07-2011 , 08:34   Re: Add menu item only if it hasn't been add before
Reply With Quote #2

hook trough all lines, and check isn't the line equal to any other line. if yes, just skip it with continue;
reinert is offline
FEELiFE
Member
Join Date: Jul 2010
Old 05-07-2011 , 08:38   Re: Add menu item only if it hasn't been add before
Reply With Quote #3

Quote:
Originally Posted by reinert View Post
hook trough all lines, and check isn't the line equal to any other line. if yes, just skip it with continue;
Yes, but can you give me an example, please?
FEELiFE is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-07-2011 , 09:18   Re: Add menu item only if it hasn't been add before
Reply With Quote #4

Create a Trie before you parse the file, add any new item in the Trie if the key doesn't already exist, else don't create a new item.
When you have finished you can destroy the trie.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 04:28.


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