亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? sect07.htm

?? this is the most basic to learn python
?? HTM
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<!--
This document was converted from RTF source: 
By rtftohtml 4.19
See http://www.sunpack.com/RTF
Filename:TIPython.rtf
Application Directory:c:\tools\rtf2html\
Subject:
Author:Bruce Eckel
Operator:Bruce Eckel
Document Comments:
Version Comments:
Comments:
Keywords:
Translation Date:12/31/2001
Translation Time:08:24:13
Translation Platform:Win32
Number of Output files:18
This File:Sect07.htm
SplitDepth=1
SkipNavPanel=1
SkipLeadingToc=1
SkipTrailingToc=1
GenContents=1
GenFrames=1
GenIndex=1
-->
<HEAD lang="en"><META http-equiv="Content-Type" content="text/html">
<TITLE>Y: Iterators: decoupling algorithms from containers</TITLE>

<script language="JavaScript">
</script>
</head>


<BODY  BGCOLOR="#FFFFFF"><DIV ALIGN="CENTER">
  <a href="http://www.MindView.net">
  <img src="mindview.gif" alt="MindView Inc." BORDER = "0"></a>
  <CENTER>
    <FONT FACE="Verdana, Tahoma, Arial, Helvetica, Sans" size = "-1">
    <!-- [ <a href="README.txt">Viewing Hints</a> ]
    [ <a href="RevisionHistory.htm">Revision History</a> ] -->
    [ <a href="http://www.mindview.net/Books/TIPython/">Book Home Page</a> ]
    [ <a href="http://www.mindview.net/Etc/MailingList.html">Free Newsletter</a> ] <br>
    [ <a href="http://www.mindview.net/Seminars">Seminars</a> ]
    [ <a href="http://www.mindview.net/CDs">Seminars on CD ROM</a> ]
    [ <a href="http://www.mindview.net/Services">Consulting</a> ]
    </FONT>
  <H2><FONT FACE="Verdana, Tahoma, Arial, Helvetica, Sans">
  Thinking in Python<br>
  <small>Revision 0.1.2 (12/31/01) -- Incomplete and Unfinished</small></FONT></H2>
  <H3><FONT FACE="Verdana, Tahoma, Arial, Helvetica, Sans">
  by Bruce Eckel &copy;2002 MindView, Inc.</FONT></H3>
  
    <FONT FACE="Verdana, Tahoma, Arial, Helvetica, Sans" size = "-1">
     [ <a href="Sect06.htm">Previous Chapter</a> ] 
    
    [ <a href="javascript:window.location.href = 'Index.htm';">Table of Contents</a> ] 
  
        [ <a href="DocIdx.htm">Index</a> ]
        
     [ <a href="Sect08.htm">Next Chapter</a> ] 
    </FONT>
    
  </CENTER>
  </P></DIV><A NAME="_Toc534420105"></A><A NAME="Heading56"></A><FONT FACE = "Verdana, Tahoma, Arial, Helvetica, Sans"><H1 ALIGN="LEFT">
Y: Iterators: decoupling algorithms from containers</H1></FONT>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia" SIZE=4 COLOR="Red">This chapter has not
had any significant translation yet.</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia" SIZE=4>Alexander Stepanov thought for
years about the problem of generic programming techniques before creating the
STL (along with Dave Musser). He came to the conclusion that all algorithms are
defined on algebraic structures &#150; what we would call containers.
<A HREF="http://www.mindview.net/Books/TIPython/BackTalk/FindPage/A_231">Add Comment</A></FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">In the process, he realized that
iterators are central to the use of algorithms, because they decouple the
algorithms from the specific type of container that the algorithm might
currently be working with. This means that you can describe the algorithm
without worrying about the particular sequence it is operating on. More
generally, <I>any</I> code that you write using iterators is decoupled from the
data structure that the code is manipulating, and thus your code is more general
and reusable.
<A HREF="http://www.mindview.net/Books/TIPython/BackTalk/FindPage/A_232">Add Comment</A></FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">The use of iterators also extends your
code into the realm of <I>functional programming</I>, whose objective is to
describe <I>what</I> a program is doing at every step rather than <I>how</I> it
is doing it. That is, you say &#147;sort&#148; rather than describing the
sort. The objective of the C++ STL was to provide this <I>generic
programming</I> approach for C++ (how successful this approach will actually be
remains to be seen).
<A HREF="http://www.mindview.net/Books/TIPython/BackTalk/FindPage/A_233">Add Comment</A></FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">If you&#146;ve used containers in Java
(and it&#146;s hard to write code without using them), you&#146;ve used
iterators &#150; in the form of the <B>Enumeration</B> in Java 1.0/1.1 and the
<B>Iterator</B> in Java 2. So you should already be familiar with their general
use. If not, see Chapter 9, <I>Holding Your Objects</I>, under <I>Iterators</I>
in <I>Thinking in Java, 2<SUP>nd</SUP> edition</I> (freely downloadable from
<I>www.BruceEckel.com</I>).
<A HREF="http://www.mindview.net/Books/TIPython/BackTalk/FindPage/A_234">Add Comment</A></FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">Because the Java 2 containers rely
heavily on iterators they become excellent candidates for generic/functional
programming techniques. This chapter will explore these techniques by converting
the STL algorithms to Java, for use with the Java 2 container library.
<A HREF="http://www.mindview.net/Books/TIPython/BackTalk/FindPage/A_235">Add Comment</A></FONT><A NAME="_Toc534420106"></A><BR></P></DIV>
<A NAME="Heading57"></A><FONT FACE = "Verdana, Tahoma, Arial, Helvetica, Sans"><H2 ALIGN="LEFT">
Type-safe iterators</H2></FONT>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">In <I>Thinking in Java, 2<SUP>nd</SUP>
edition</I>, I show the creation of a type-safe container that will only accept
a particular type of object. A reader, Linda Pazzaglia, asked for the other
obvious type-safe component, an iterator that would work with the basic
<B>java.util</B> containers, but impose the constraint that the type of objects
that it iterates over be of a particular type.
<A HREF="http://www.mindview.net/Books/TIPython/BackTalk/FindPage/A_236">Add Comment</A></FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">If Java ever includes a template
mechanism, this kind of iterator will have the added advantage of being able to
return a specific type of object, but without templates you are forced to return
generic <B>Object</B>s, or to require a bit of hand-coding for every type that
you want to iterate through. I will take the former approach.
<A HREF="http://www.mindview.net/Books/TIPython/BackTalk/FindPage/A_237">Add Comment</A></FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">A second design decision involves the
time that the type of object is determined. One approach is to take the type of
the first object that the iterator encounters, but this is problematic because
the containers may rearrange the objects according to an internal ordering
mechanism (such as a hash table) and thus you may get different results from one
iteration to the next. The safe approach is to require the user to establish the
type during construction of the iterator.
<A HREF="http://www.mindview.net/Books/TIPython/BackTalk/FindPage/A_238">Add Comment</A></FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">Lastly, how do we build the iterator? We
cannot rewrite the existing Java library classes that already produce
<B>Enumeration</B>s and <B>Iterator</B>s. However, we can use the
<I>Decorator</I> design pattern, and create a class that simply wraps the
<B>Enumeration</B> or <B>Iterator</B> that is produced, generating a new object
that has the iteration behavior that we want (which is, in this case, to throw a
<B>RuntimeException</B> if an incorrect type is encountered) but with the same
interface as the original <B>Enumeration</B> or <B>Iterator</B>, so that it can
be used in the same places (you may argue that this is actually a <I>Proxy</I>
pattern, but it&#146;s more likely <I>Decorator</I> because of its intent).
Here is the code:
<A HREF="http://www.mindview.net/Books/TIPython/BackTalk/FindPage/A_239">Add Comment</A></FONT><BR></P></DIV>

<BLOCKQUOTE><FONT SIZE = "+1"><PRE># util:TypedIterator.py

<font color=#0000ff>class</font> TypedIterator(Iterator):
  private Iterator imp
  private Class type
  <font color=#0000ff>def</font> __init__(self, Iterator it, Class type):
    imp = it
    self.type = type

  <font color=#0000ff>def</font> hasNext(self): 
    <font color=#0000ff>return</font> imp.hasNext() 

  <font color=#0000ff>def</font> remove(self): imp.remove() 
  <font color=#0000ff>def</font> next(self):
    Object obj = imp.next()
    <font color=#0000ff>if</font>(!type.isInstance(obj))
      throw ClassCastException(
        <font color=#004488>"TypedIterator for type "</font> + type +
        <font color=#004488>" encountered type: "</font> + obj.getClass())
    <font color=#0000ff>return</font> obj
# :~</PRE></FONT></BLOCKQUOTE>
<DIV ALIGN="CENTER">
    <FONT FACE="Verdana, Tahoma, Arial, Helvetica, Sans" size = "-1">
     [ <a href="Sect06.htm">Previous Chapter</a> ] 
    
    [ <a href="javascript:window.location.href = 'Index.htm';">Table of Contents</a> ] 
  
        [ <a href="DocIdx.htm">Index</a> ]
        
     [ <a href="Sect08.htm">Next Chapter</a> ] 
    </FONT>
    <BR>
 Last Update:12/31/2001</P></DIV>

</BODY>

</HTML>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧洲日本在线| 日韩欧美黄色影院| 亚洲三级小视频| 国产精品国产三级国产普通话99| 在线精品观看国产| 精品久久久影院| 国产乱国产乱300精品| 欧美激情自拍偷拍| 91在线porny国产在线看| 亚洲人被黑人高潮完整版| 欧美制服丝袜第一页| 日韩不卡一区二区| 久久久影视传媒| av电影天堂一区二区在线| 亚洲一区二区在线播放相泽| 日韩一区二区三区高清免费看看| 国产在线不卡一区| 亚洲柠檬福利资源导航| 欧美肥妇free| 福利一区二区在线| 亚洲图片欧美色图| 久久综合九色综合久久久精品综合| 丁香婷婷综合激情五月色| 亚洲一区国产视频| 天天综合色天天综合| 国产剧情一区在线| 麻豆精品在线播放| 国产精品久久久久影视| 91蜜桃传媒精品久久久一区二区| 亚洲午夜久久久久久久久电影网| 欧美岛国在线观看| 色婷婷激情久久| 韩国女主播成人在线观看| 国产精品麻豆久久久| 91 com成人网| 99精品视频一区二区三区| 蜜臀久久久99精品久久久久久| 国产精品福利一区| 日韩欧美亚洲国产另类| 91视频com| 国内精品第一页| 亚洲va天堂va国产va久| 国产午夜亚洲精品不卡| 欧美一区二区视频在线观看| 不卡电影免费在线播放一区| 免费不卡在线视频| 玉足女爽爽91| 欧美人妇做爰xxxⅹ性高电影| 日本精品一级二级| 紧缚奴在线一区二区三区| 亚洲你懂的在线视频| 国产欧美一区二区精品久导航| 欧美日韩不卡视频| 色综合久久综合网欧美综合网 | 精品日韩99亚洲| 91在线播放网址| 国产乱码字幕精品高清av | 久久美女艺术照精彩视频福利播放 | 国产视频视频一区| 欧美一区二区三区在线电影| 国产一区在线观看麻豆| 日韩欧美一区二区不卡| 午夜一区二区三区视频| 91在线云播放| 亚洲国产高清在线观看视频| 欧美午夜精品久久久| 99re热这里只有精品视频| 国产一区欧美一区| 国产毛片精品国产一区二区三区| 日韩1区2区日韩1区2区| 日本伊人色综合网| 日韩—二三区免费观看av| 天堂av在线一区| 亚洲欧美视频在线观看视频| 综合久久综合久久| 亚洲伦理在线免费看| 自拍偷自拍亚洲精品播放| 国产精品久久免费看| 国产精品久久久久一区二区三区 | 欧美三级中文字| 色哟哟一区二区在线观看 | 国产电影一区二区三区| 国产一区二区三区不卡在线观看| 久久99久久久久| 久久99国产精品成人| 免费人成在线不卡| 美女www一区二区| 国产自产高清不卡| 粉嫩13p一区二区三区| 99精品视频中文字幕| 色香色香欲天天天影视综合网| 色综合中文字幕| 欧美日韩一区 二区 三区 久久精品| 欧美日韩在线亚洲一区蜜芽| 91精品国产综合久久久久久| 日韩视频免费观看高清在线视频| 精品久久久久久综合日本欧美| 久久综合色天天久久综合图片| 国产精品少妇自拍| 综合av第一页| 日韩av电影免费观看高清完整版 | 亚洲一区二区偷拍精品| 亚洲成va人在线观看| 蜜桃av一区二区三区| 国产乱码一区二区三区| 91网站最新地址| 欧美日本在线看| 精品国产乱码久久久久久闺蜜| 欧美激情自拍偷拍| 午夜精品爽啪视频| 国产资源在线一区| 色婷婷激情综合| 精品国产91久久久久久久妲己| 国产午夜精品久久久久久免费视 | 亚洲与欧洲av电影| 久久国产精品露脸对白| 粉嫩在线一区二区三区视频| 欧洲精品一区二区| 久久精品免视看| 亚洲成人精品影院| 大桥未久av一区二区三区中文| 欧美三级电影在线看| 久久久影院官网| 偷拍一区二区三区四区| 国产成人av福利| 欧美精品第1页| 国产精品久久久久毛片软件| 午夜精品福利视频网站| 国产成人免费视频网站| 在线不卡免费欧美| 国产精品久久久久久户外露出| 日日夜夜精品免费视频| 9色porny自拍视频一区二区| 日韩一区二区三区视频在线观看| 亚洲欧美视频在线观看视频| 国产在线精品免费| 91麻豆精品国产91久久久使用方法 | 日韩伦理av电影| 久久99精品国产.久久久久| 一本色道亚洲精品aⅴ| 久久久久久电影| 五月天一区二区三区| 一本到三区不卡视频| 国产日产精品一区| 国产真实精品久久二三区| 这里只有精品99re| 亚洲成av人片在线观看无码| 99精品视频一区| 国产亲近乱来精品视频| 精品一区二区三区免费毛片爱| 欧美日韩亚洲另类| 亚洲黄色av一区| 91麻豆国产福利在线观看| 国产色一区二区| 国产主播一区二区| 精品国产三级电影在线观看| 青娱乐精品在线视频| 911精品国产一区二区在线| 一区二区三区不卡在线观看| 色综合久久中文综合久久97| 亚洲欧洲韩国日本视频| 国产91精品露脸国语对白| 久久嫩草精品久久久精品| 久久99蜜桃精品| 精品国产凹凸成av人导航| 久久不见久久见中文字幕免费| 777亚洲妇女| 久久精品国产秦先生| 日韩欧美亚洲另类制服综合在线| 丝袜美腿亚洲一区二区图片| 欧美在线看片a免费观看| 亚洲女厕所小便bbb| 欧美午夜电影一区| 丝袜亚洲另类欧美| 日韩欧美国产一区二区在线播放| 美女免费视频一区二区| 欧美一区二区三区四区五区 | 国产片一区二区| 成人动漫中文字幕| 亚洲欧美在线观看| 91亚洲精品一区二区乱码| 亚洲永久精品国产| 欧美老肥妇做.爰bbww视频| 日韩极品在线观看| 久久影音资源网| 大桥未久av一区二区三区中文| 亚洲手机成人高清视频| 欧美婷婷六月丁香综合色| 午夜精品一区二区三区三上悠亚 | 欧美日本一区二区三区| 免费在线观看一区| 国产亚洲成av人在线观看导航| 国产99久久久国产精品潘金| 亚洲美女屁股眼交| 欧美一区二区免费视频| 国产成人在线网站| 亚洲国产成人av| 久久久一区二区三区捆绑**| 99精品一区二区三区| 日韩极品在线观看|