Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #2729

Re: using TreeMap how to return the Object ?

From Jeff Higgins <jeff@invalid.invalid>
Newsgroups comp.lang.java.help
Subject Re: using TreeMap how to return the Object ?
Date 2013-06-27 13:15 -0400
Organization A noiseless patient Spider
Message-ID <kqhrjo$u2d$1@dont-email.me> (permalink)
References <f11f9858-f870-42af-a3a3-e9fdb945ba41@googlegroups.com> <kqhkq6$k8g$1@dont-email.me>

Show all headers | View raw


On 06/27/2013 11:19 AM, Jeff Higgins wrote:
> On 06/27/2013 01:30 AM, moonhkt wrote:
>> Hi All
>>

public class HostsTest {

   private final Hosts hosts;

   { hosts = new Hosts(); }

   public static void main(String[] args) {
     HostsTest test = new HostsTest();
     test.fillHosts("\\etc\\hosts");
   }

   public boolean fillHosts(String filename) {

     /*
      * TODO
      */

     return false;
   }

   public Host getHost(IPAddress address) {

     /*
      * TODO
      */

     return null;
   }

}

public class IPAddress implements Comparable<IPAddress> {

   /*
    * IPV4 addresses are 32 bit values
    * IPV6 addresses are 128 bit values
    * (non-Javadoc)
    * @see java.lang.Comparable#compareTo(java.lang.Object)
    */

   // some private final field to hold your address value.
   // some constructor(s)

   @Override
   public int compareTo(IPAddress address) {
     // TODO Auto-generated method stub
     return 0;
   }

   @Override
   public int hashCode() {
     // TODO Auto-generated method stub
     return super.hashCode();
   }

   @Override
   public boolean equals(Object obj) {
     // TODO Auto-generated method stub
     return super.equals(obj);
   }

   @Override
   public String toString() {
     // TODO Auto-generated method stub
     return super.toString();
   }
}

import java.util.ArrayList;
import java.util.List;

public class Host {

   private final String hostName;
   private final List<String> aliases;

   { aliases = new ArrayList<String>(); }

   public Host(String hostname) {
     hostName = hostname;
   }

   /*
    * TODO
    */

}

import java.util.Map;
import java.util.TreeMap;


public class Hosts {

   private final Map<IPAddress, Host> map;

   { map = new TreeMap<IPAddress, Host>(); }

   public Host getHostFromIPAddress(IPAddress address) {

     /*
      * TODO
      */

     return null;
   }

}


Back to comp.lang.java.help | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

using TreeMap how to return the Object ? moonhkt <moonhkt@gmail.com> - 2013-06-26 22:30 -0700
  Re: using TreeMap how to return the Object ? Jeff Higgins <jeff@invalid.invalid> - 2013-06-27 11:19 -0400
    Re: using TreeMap how to return the Object ? Jeff Higgins <jeff@invalid.invalid> - 2013-06-27 13:15 -0400
    Re: using TreeMap how to return the Object ? Jeff Higgins <jeff@invalid.invalid> - 2013-07-01 10:49 -0400
  Re: using TreeMap how to return the Object ? Lew <lewbloch@gmail.com> - 2013-06-28 10:42 -0700
    Re: using TreeMap how to return the Object ? Patricia Shanahan <pats@acm.org> - 2013-06-28 19:13 -0700
      Re: using TreeMap how to return the Object ? Gene Wirchenko <genew@telus.net> - 2013-07-01 14:16 -0700

csiph-web