丄諦啲仇魜ヤ
          如 果 敵 人 讓 你 生 氣 , 那 說 明 你 沒 有 勝 他 的 把 握!
          posts - 6,comments - 56,trackbacks - 1
          以前寫的一個遍歷算法,以后也應該用得著(89)

          /*
               * @author 於良偉
               *       根先序遍歷算法
               * @param bizes  所選的遍歷總數據
               * @param bizID 當前遍歷的根節點id
               * @param treeList 遍歷返回結果
               * @return void
               *
               * */
              private void traversal(List bizes,Long bizID, List treeList) {
                       for (int i = 0; i < bizes.size(); i++) {
                           Business business = (Business) bizes.get(i);
                           if (business.getParentBusiness()!=null && bizID.equals(business.getParentBusiness().getId())) {
                               /*如果當前節點存在父節點并且當前節點的父節點編號與bizID相同,則添加到treeList*/
                               treeList.add(business);
                               /*遍歷*/
                               traversal(bizes,business.getId(),treeList);
                           }

                       } //for
              }

           

          /*
               * @author 於良偉
               *     根據所選收支類型創建樹
               * @param  biz  所選節點
               * @param  IOflag 收支類型
               * @return  List treeList
               *
               *
               * */
              public List builderTreeByBiz(final Business biz,final Integer IOflag){
                  /*從指定節點構造收支類型樹結構的List*/
                  List treeList = new ArrayList();

                  if (biz==null) {
                      /*如果biz為空,返回空List*/
                      return treeList;
                  }

                  /*添加biz到treeList*/
                  treeList.add(biz);
                  /*根先序遍歷*/
                  traversal(getBusinessByDepartment(biz.getDept(),IOflag),biz.getId(),treeList);

                  return treeList;

              }

          posted on 2007-09-27 18:58 Crying 閱讀(235) 評論(0)  編輯  收藏 所屬分類: 算法

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 临湘市| 延边| 兴义市| 宜黄县| 闸北区| 东辽县| 河北区| 四平市| 梁平县| 合阳县| 勃利县| 射阳县| 景德镇市| 化州市| 麻阳| 肥乡县| 视频| 道真| 出国| 雅安市| 临邑县| 柞水县| 深水埗区| 赤峰市| 鲜城| 迭部县| 饶阳县| 陆良县| 镇江市| 黔西| 漳浦县| 崇礼县| 岳阳市| 普洱| 吉水县| 乐至县| 平塘县| 于田县| 石楼县| 定襄县| 浦江县|