posts - 431,  comments - 344,  trackbacks - 0
          公告
           Don't Repeat Yourself
          座右銘:you can lose your money, you can spent all of it, and if you work hard you get it all back. But if you waste your time, you're never gonna get it back.
          公告本博客在此聲明部分文章為轉摘,只做資料收集使用。


          微信: szhourui
          QQ:109450684
          Email
          lsi.zhourui@gmail.com
          <2009年8月>
          2627282930311
          2345678
          9101112131415
          16171819202122
          23242526272829
          303112345

          留言簿(15)

          隨筆分類(1019)

          文章分類(3)

          文章檔案(21)

          收藏夾

          Link

          好友博客

          最新隨筆

          搜索

          •  

          積分與排名

          • 積分 - 861069
          • 排名 - 44

          最新評論

          閱讀排行榜

          JQL is an extension for Java that provides support for querying collections of objects. These queries can be run over objects in collections in your program, or even used to check expressions on all instances of specific types at runtime.

          Queries provide a powerful abstraction for dealing with sets of objects, allowing the query engine to take care of the implementation details. This allows for shorter, clearer code, and permits the query engine to dynamically optimize query evaluation strategies as the runtime context changes.

          Queries can also be cached and that cache incrementally maintained - this greatly increases their efficiency, and can offer improved performance for many common collection operations.

          A brief example!

          Say we're building a crossword puzzle. We've got a list of candidate words for our puzzle, and a list of the lengths of the gaps we need to fill:
          ArrayList<String> words = dict.getWords(Puzzle.MEDIUM);
          ArrayList<Integer> gaplengths = puzzle.getGapLengths();

          Now we've got a truly marvelous algorithm for building a crossword puzzle (that this webpage is too narrow to contain), which relies on having a list of pairs of [length, word].
          Using a JQL query, we can build this list with ease:
          List<Object[]> matches = selectAll(String w : words,
                                             Integer i : gaplengths |
                                             w.length() == i);
          Contrast with how we could do this in normal Java:
          List<Object[]> matches = new ArrayList<Object[]>();
          for(String w : words){
            for(Integer i : gaplengths){
              if(w.length() == i)
                matches.add(new Object[i,w]);
            }
          }
          The JQL query and the Java code will produce the same list of results - but the JQL version is shorter, neater, and abstracts away the exact method of finding the matches. For a more in-depth look on why this can be helpful, please look at our Examples page.

          下載地址:http://homepages.mcs.vuw.ac.nz/~djp/jql/download.html
          posted on 2009-08-06 09:11 周銳 閱讀(294) 評論(0)  編輯  收藏 所屬分類: Java
          主站蜘蛛池模板: 北海市| 依安县| 精河县| 津市市| 平阳县| 枣庄市| 巴林右旗| 友谊县| 新龙县| 广河县| 平江县| 丰顺县| 澎湖县| 永定县| 高阳县| 康平县| 长武县| 长寿区| 巫溪县| 双流县| 徐汇区| 周口市| 白城市| 吉木乃县| 吴堡县| 安阳市| 牙克石市| 万盛区| 垣曲县| 商河县| 于田县| 凉城县| 宣汉县| 金山区| 天等县| 华坪县| 华池县| 临汾市| 绥中县| 英德市| 合江县|