Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 3rd, 2006, 11:38 AM   #1
Samuaijack
Programmer
 
Samuaijack's Avatar
 
Join Date: Jul 2006
Location: using Earth.Africa.Egypt.Cairo;
Posts: 73
Rep Power: 3 Samuaijack is on a distinguished road
About arrays

hey guys,
well i was just wndering if i can delete indexes from an array,for an example if i have a string entered by the user then i took every word in the string into an index of this array but if i have a few indexes in this array that remain null can i delete them ??
Samuaijack is online now   Reply With Quote
Old Aug 3rd, 2006, 11:58 AM   #2
JimmyJim
Programmer
 
JimmyJim's Avatar
 
Join Date: Jul 2006
Location: England
Posts: 43
Rep Power: 0 JimmyJim is on a distinguished road
Take a look at System.Collections.Generic namespace. There is List<T> which is far far more useful than just a standard Array. There are also other classes in that namepace that act differently but also might be useful.

You cant just remove an item on an array. You have to copy it into a new array up to the point where you want to remove. In your case you would check for nulls to find out where you would stop. You then skip the null index and the continue copying the rest of the array checking for more nulls. I would post some code but you will learn more if you figure it out.
JimmyJim is offline   Reply With Quote
Old Aug 3rd, 2006, 4:35 PM   #3
Samuaijack
Programmer
 
Samuaijack's Avatar
 
Join Date: Jul 2006
Location: using Earth.Africa.Egypt.Cairo;
Posts: 73
Rep Power: 3 Samuaijack is on a distinguished road
thnx jimmy i will try that.
Samuaijack is online now   Reply With Quote
Old Aug 5th, 2006, 4:19 PM   #4
kurifu
Expert Programmer
 
kurifu's Avatar
 
Join Date: Jul 2004
Location: Halifax, Nova Scotia (Canada)
Posts: 784
Rep Power: 5 kurifu is on a distinguished road
Send a message via ICQ to kurifu Send a message via MSN to kurifu
If you delete an index from an array there remains a gap there in the memory unless you write some sort of funtion to copy all data past the point backward one index to fill the gap. Same behaviour as you would expect in C++, and well many languages I am sure.

List<T> is a great solution to this since it provides funtions which will do exactly that for you!

Oh of course the othe option too is to use something like a linked list which would be faster because your wouldn't be copying data around your memory so much, you just have to update the links between two of the indexes.
__________________
Clifford Matthew Roche &lt;geek@cliffordroche.com&gt;
Web Hosting: http://www.crd-hosting.com
Consulting: http://www.crdev-consulting.com
kurifu is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Arrays or Vectors? can342man C++ 2 Apr 20th, 2006 3:57 PM
searching for 2D arrays within 2D arrays HammerCat C++ 9 Mar 14th, 2006 9:16 AM
Getting values of (non-dynamic) arrays... Mcoy C++ 3 Mar 2nd, 2006 7:25 PM
Arrays in PHP MrMan9879 PHP 6 Jan 12th, 2006 9:18 PM
Arrays Gunman C++ 17 Oct 20th, 2005 6:11 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:57 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC