public List<Page> expandPages(List<Page> pages){
  List<Page> expandedPages=new ArrayList<Page>();
  Set<String> inAndOutLinks=new HashSet<String>();
  for (int i=0; i < pages.size(); i++) {
    Page currP=pages.get(i);
    if (!expandedPages.contains(currP)) {
      expandedPages.add(currP);
    }
    List<String> currInlinks=currP.getInlinks();
    for (int j=0; j < currInlinks.size(); j++) {
      inAndOutLinks.add(currInlinks.get(i));
    }
    List<String> currOutlinks=currP.getOutlinks();
    for (int j=0; j < currOutlinks.size(); j++) {
      inAndOutLinks.add(currOutlinks.get(i));
    }
  }
  Iterator<String> it=inAndOutLinks.iterator();
  while (it.hasNext()) {
    String addr=it.next();
    Page p=pTable.get(addr);
    if (p != null && !expandedPages.contains(p)) {
      expandedPages.add(p);
    }
  }
  return expandedPages;
}

public List < Page > expandPages ( List < Page > pages ) { List < Page > expandedPages = new ArrayList < Page > ( ) ; Set < String > inAndOutLinks = new HashSet < String > ( ) ; for ( int i = 0 ; i < pages . size ( ) ; i ++ ) { Page currP = pages . get ( i ) ; if ( ! expandedPages . contains ( currP ) ) { expandedPages . add ( currP ) ; } List < String > currInlinks = currP . getInlinks ( ) ; for ( int j = 0 ; j < currInlinks . size ( ) ; j ++ ) { inAndOutLinks . add ( currInlinks . get ( i ) ) ; } List < String > currOutlinks = currP . getOutlinks ( ) ; for ( int j = 0 ; j < currOutlinks . size ( ) ; j ++ ) { inAndOutLinks . add ( currOutlinks . get ( i ) ) ; } } Iterator < String > it = inAndOutLinks . iterator ( ) ; while ( it . hasNext ( ) ) { String addr = it . next ( ) ; Page p = pTable . get ( addr ) ; if ( p != null && ! expandedPages . contains ( p ) ) { expandedPages . add ( p ) ; } } return expandedPages ; }
adds pages that are linked to or is linked from one of the pages passed as argument .
