Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a requirement where I need to remove a few nodes in a network based upon a command given by the user. To keep the nodes from transmitting or receiving data I thought of changing its IP address to some other address. Before I change the address I want to save the node's IP so that I can re-assign the original IP back to the node after the simulated network outage is over.

My problem is how to efficiently save the nodes' IP addresses. Should I use a linked list or a hash table?

share|improve this question

closed as not a real question by Dynamic, Yusubov, Walter, gnat, GlenH7 Dec 22 '12 at 2:27

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

How efficiently do you need store those IP addresses? Are you planning to store 20000 of them? Or 20? How about just using a simple array? p.s. 20k is still a relatively small number – DXM Dec 21 '12 at 14:21
Could you do it at the underlying system level?… – user40980 Dec 21 '12 at 14:23
There are a zillion other, better, ways to simulate network outages. Better yet, just down the interface and be done with it. – Blrfl Dec 21 '12 at 16:31
Define "efficiently". Fast for storage? Fast for retrieval? Efficient in terms of memory usage? Does this question actually have anything to do with IP addresses, or are you just asking for a data storage system? – Trevor Powell Dec 21 '12 at 19:19

IP(v4) addresses are just four byte long integers presented in a human readable format. You can just store an IP address as an unsigned integer.

share|improve this answer
Not to mention that all the netmask arithmetic becomes much easier to do on one big value anyway. – mikebabcock Dec 21 '12 at 17:27

To keep the nodes from transmitting or receiving data I thought of changing its IP address to some other address.

That is a very dicey solution to your stated problem. You don't need to worry too much about efficiently storing IP Addresses if your solution doesn't involve this sort of hack.

share|improve this answer
Might be more appropriate as a comment. As it does not answer the question. – Loki Astari Dec 22 '12 at 2:25

Personally I would change a single digit of the IP, eg from to

share|improve this answer
One line answers rarely add a lot of value and this doesn't really answer the question. Please consider expanding upon your answer. – Walter Dec 21 '12 at 15:59
It's not really possible to expand the answer without more detail from the poster, although I don't think there will be a more efficient way to do it. – bendataclear Dec 21 '12 at 16:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.