ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 02.01.2026
Просмотров: 3413
Скачиваний: 0
|
Contents |
xix |
27.4 |
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . |
654 |
28 Working with XML |
655 |
|
28.1 |
Semi-structured data . . . . . . . . . . . . . . . . . . . |
655 |
28.2 |
XML overview . . . . . . . . . . . . . . . . . . . . . . |
656 |
28.3 |
XML literals . . . . . . . . . . . . . . . . . . . . . . . |
657 |
28.4 |
Serialization . . . . . . . . . . . . . . . . . . . . . . . |
659 |
28.5 |
Taking XML apart . . . . . . . . . . . . . . . . . . . . |
661 |
28.6 |
Deserialization . . . . . . . . . . . . . . . . . . . . . . |
662 |
28.7 |
Loading and saving . . . . . . . . . . . . . . . . . . . |
663 |
28.8 |
Pattern matching on XML . . . . . . . . . . . . . . . . |
665 |
28.9 |
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . |
668 |
29 Modular Programming Using Objects |
669 |
|
29.1 |
The problem . . . . . . . . . . . . . . . . . . . . . . . |
670 |
29.2 |
A recipe application . . . . . . . . . . . . . . . . . . . |
671 |
29.3 |
Abstraction . . . . . . . . . . . . . . . . . . . . . . . . |
674 |
29.4 |
Splitting modules into traits . . . . . . . . . . . . . . . |
677 |
29.5 |
Runtime linking . . . . . . . . . . . . . . . . . . . . . |
680 |
29.6 |
Tracking module instances . . . . . . . . . . . . . . . . |
681 |
29.7 |
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . |
683 |
30 Object Equality |
684 |
|
30.1 |
Equality in Scala . . . . . . . . . . . . . . . . . . . . . |
684 |
30.2 |
Writing an equality method . . . . . . . . . . . . . . . |
685 |
30.3 |
Defining equality for parameterized types . . . . . . . . |
698 |
30.4 |
Recipes for equals and hashCode . . . . . . . . . . . |
703 |
30.5 |
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . |
709 |
31 Combining Scala and Java |
710 |
|
31.1 |
Using Scala from Java . . . . . . . . . . . . . . . . . . |
710 |
31.2 |
Annotations . . . . . . . . . . . . . . . . . . . . . . . |
713 |
31.3 |
Existential types . . . . . . . . . . . . . . . . . . . . . |
718 |
31.4 |
Using synchronized . . . . . . . . . . . . . . . . . . |
722 |
31.5 |
Compiling Scala and Java together . . . . . . . . . . . |
722 |
31.6 |
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . |
723 |
32 Actors and Concurrency |
724 |
|
Cover · Overview · Contents · Discuss · Suggest · Glossary · Index
|
Contents |
xx |
32.1 |
Trouble in paradise . . . . . . . . . . . . . . . . . . . . |
724 |
32.2 |
Actors and message passing . . . . . . . . . . . . . . . |
725 |
32.3 |
Treating native threads as actors . . . . . . . . . . . . . |
729 |
32.4 |
Better performance through thread reuse . . . . . . . . |
730 |
32.5 |
Good actors style . . . . . . . . . . . . . . . . . . . . . |
733 |
32.6 |
A longer example: Parallel discrete event simulation . . |
740 |
32.7 |
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . |
757 |
33 Combinator Parsing |
759 |
|
33.1 |
Example: Arithmetic expressions . . . . . . . . . . . . |
760 |
33.2 |
Running your parser . . . . . . . . . . . . . . . . . . . |
762 |
33.3 |
Basic regular expression parsers . . . . . . . . . . . . . |
763 |
33.4 |
Another example: JSON . . . . . . . . . . . . . . . . . |
764 |
33.5 |
Parser output . . . . . . . . . . . . . . . . . . . . . . . |
766 |
33.6 |
Implementing combinator parsers . . . . . . . . . . . . |
772 |
33.7 |
String literals and regular expressions . . . . . . . . . . |
781 |
33.8 |
Lexing and parsing . . . . . . . . . . . . . . . . . . . . |
782 |
33.9 |
Error reporting . . . . . . . . . . . . . . . . . . . . . . |
782 |
33.10 |
Backtracking versus LL(1) . . . . . . . . . . . . . . . . |
784 |
33.11 |
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . |
786 |
34 GUI Programming |
788 |
|
34.1 |
A first Swing application . . . . . . . . . . . . . . . . . |
788 |
34.2 |
Panels and layouts . . . . . . . . . . . . . . . . . . . . |
791 |
34.3 |
Handling events . . . . . . . . . . . . . . . . . . . . . |
793 |
34.4 |
Example: Celsius/Fahrenheit converter . . . . . . . . . |
796 |
34.5 |
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . |
798 |
35 The SCells Spreadsheet |
800 |
|
35.1 |
The visual framework . . . . . . . . . . . . . . . . . . |
800 |
35.2 |
Disconnecting data entry and display . . . . . . . . . . |
803 |
35.3 |
Formulas . . . . . . . . . . . . . . . . . . . . . . . . . |
806 |
35.4 |
Parsing formulas . . . . . . . . . . . . . . . . . . . . . |
808 |
35.5 |
Evaluation . . . . . . . . . . . . . . . . . . . . . . . . |
813 |
35.6 |
Operation libraries . . . . . . . . . . . . . . . . . . . . |
816 |
35.7 |
Change propagation . . . . . . . . . . . . . . . . . . . |
819 |
35.8 |
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . |
823 |
Cover · Overview · Contents · Discuss · Suggest · Glossary · Index
Contents |
xxi |
A Scala Scripts on Unix and Windows |
825 |
Glossary |
826 |
Bibliography |
842 |
About the Authors |
845 |
Index |
846 |
Cover · Overview · Contents · Discuss · Suggest · Glossary · Index
List of Figures
2.1 |
The basic form of a function definition in Scala. . . . . . . . |
73 |
2.2 |
The syntax of a function literal in Scala. . . . . . . . . . . . |
79 |
3.1 |
All operations are method calls in Scala. . . . . . . . . . . . |
84 |
3.2 |
Class hierarchy for Scala sets. . . . . . . . . . . . . . . . . |
92 |
3.3 |
Class hierarchy for Scala maps. . . . . . . . . . . . . . . . . |
94 |
10.1 |
Class diagram for ArrayElement. . . . . . . . . . . . . . . |
228 |
10.2 |
Class diagram for LineElement. . . . . . . . . . . . . . . . |
233 |
10.3 |
Class hierarchy of layout elements. . . . . . . . . . . . . . . |
236 |
10.4 |
Class hierarchy with revised LineElement. . . . . . . . . . |
240 |
11.1 |
Class hierarchy of Scala. . . . . . . . . . . . . . . . . . . . |
252 |
12.1 |
Inheritance hierarchy and linearization of class Cat. . . . . . |
274 |
14.1 |
ScalaTest’s graphical reporter. . . . . . . . . . . . . . . . . |
307 |
18.1 |
Basic gates. . . . . . . . . . . . . . . . . . . . . . . . . . . |
406 |
18.2 |
A half-adder circuit. . . . . . . . . . . . . . . . . . . . . . . |
408 |
18.3 |
A full-adder circuit. . . . . . . . . . . . . . . . . . . . . . . |
409 |
19.1 |
Covariance and contravariance in function type parameters. . |
441 |
22.1 |
Class hierarchy for Scala lists. . . . . . . . . . . . . . . . . |
504 |
22.2 |
The structure of the Scala lists shown in Listing 22.2. . . . . |
508 |
24.1 |
Collection hierarchy. . . . . . . . . . . . . . . . . . . . . . |
536 |
25.1 |
An example Patricia trie. . . . . . . . . . . . . . . . . . . . |
625 |
xxii
|
List of Figures |
xxiii |
34.1 |
A simple Swing application: initial (left) and resized (right). |
789 |
34.2 |
A reactive Swing application: initial (left) after clicks (right). |
791 |
34.3 |
A converter between degrees Celsius and Fahrenheit. . . . . |
796 |
35.1 |
A simple spreadsheet table. . . . . . . . . . . . . . . . . . . |
801 |
35.2 |
Cells displaying themselves. . . . . . . . . . . . . . . . . . |
806 |
35.3 |
Cells displaying their formulas. . . . . . . . . . . . . . . . . |
812 |
35.4 |
Cells that evaluate. . . . . . . . . . . . . . . . . . . . . . . |
818 |
Cover · Overview · Contents · Discuss · Suggest · Glossary · Index
List of Tables
3.1 |
Some List methods and usages . . . . . . . . . . . . . . . |
88 |
5.1 |
Some basic types . . . . . . . . . . . . . . . . . . . . . . . |
118 |
5.2 |
Special character literal escape sequences . . . . . . . . . . |
122 |
5.3 |
Operator precedence . . . . . . . . . . . . . . . . . . . . . |
135 |
5.4 |
Some rich operations . . . . . . . . . . . . . . . . . . . . |
138 |
5.5 |
Rich wrapper classes . . . . . . . . . . . . . . . . . . . . . |
138 |
12.1 |
Linearization of types in Cat’s hierarchy . . . . . . . . . . |
275 |
13.1 |
Effects of private qualifiers on LegOfJourney.distance . |
290 |
16.1 |
Basic list operations . . . . . . . . . . . . . . . . . . . . . |
347 |
17.1 |
Common operations for sets . . . . . . . . . . . . . . . . . |
384 |
17.2 |
Common operations for maps . . . . . . . . . . . . . . . . |
386 |
17.3 |
Default immutable set implementations . . . . . . . . . . . |
388 |
17.4 |
Default immutable map implementations . . . . . . . . . . |
388 |
24.1 |
Operations in trait Traversable . . . . . . . . . . . . . . |
539 |
24.2 |
Operations in trait Iterable . . . . . . . . . . . . . . . . |
544 |
24.3 |
Operations in trait Seq . . . . . . . . . . . . . . . . . . . |
548 |
24.4 |
Operations in trait Buffer . . . . . . . . . . . . . . . . . |
551 |
24.5 |
Operations in trait Set . . . . . . . . . . . . . . . . . . . |
552 |
24.6 |
Operations in trait mutable.Set . . . . . . . . . . . . . . |
553 |
24.7 |
Operations in trait Map . . . . . . . . . . . . . . . . . . . |
558 |
24.8 |
Operations in trait mutable.Map . . . . . . . . . . . . . . |
560 |
24.9 |
Operations in trait ConcurrentMap . . . . . . . . . . . . . |
577 |
24.10 |
Performance characteristics of sequence types . . . . . . . |
586 |
xxiv