Home Page Icon
Home Page
Table of Contents for
Introduction to the Art of Programming Using Scala
Close
Introduction to the Art of Programming Using Scala
by Mark C. Lewis
Introduction to the Art of Programming Using Scala
Preliminaries
Acknowledgments
Preface
To the Student
Using this Book
Book Website
To the Instructor
Using this Book
Figure 1
Figure 1
Part I Introductory Concepts
Chapter 1 Basics of Computers, Computing, and Programming
1.1 History
1.2 Hardware
1.3 Software
1.4 Nature of Programming
1.5 Programming Paradigms
1.5.1 Imperative Programming
1.5.2 Functional Programming
1.5.3 Object-Oriented Programming
1.5.4 Logic Programming
1.5.5 Nature of Scala
1.6 End of Chapter Material
1.6.1 Summary of Concepts
1.6.2 Exercises
1.6.3 Projects
Figure 1.1
Figure 1.1
Chapter 2 Getting to Know the Tools
2.1 Unix/Linux (includes Mac OS X)
2.1.1 Command-Line
2.1.1.1 Files and Directories
2.1.1.2 Aside
2.1.1.3 Helpful Tips
2.1.1.4 Permissions
2.1.1.5 Compression/Archiving
2.1.1.6 Remote
2.1.1.7 Other Commands
2.1.2 I/O Redirection
2.1.3 Text Editors (vi/vim)
2.2 Windows
2.2.1 Command-Line
2.2.1.1 Files and Directories
2.2.2 Text Editors
2.2.2.1 Edit
2.2.2.2 Notepad
2.2.2.3 Others
2.2.3 Other Commands
2.3 Scala Tools
2.4 End of Chapter Material
2.4.1 Summary of Concepts
2.4.2 Exercises
Figure 2.1
Figure 2.1
Figure 2.2
Figure 2.3
Figure 2.4
Chapter 3 Scala Basics
3.1 Expressions, Types, and Basic Math
3.2 Objects and Methods
3.3 Other Basic Types
3.4 Back to the Numbers
3.4.1 Binary Arithmetic
3.4.2 Negative Numbers in Binary
3.4.3 Other Integer Types
3.4.4 Octal and Hexadecimal
3.4.5 Non-Integer Numbers
3.5 The math Object
3.6 Details of Char and String
3.7 Naming Values and Variables
3.8 Sequential Execution
3.8.1 Comments
3.9 A Tip for Learning to Program
3.10 End of Chapter Material
3.10.1 Problem-Solving Approach
3.10.2 Summary of Concepts
3.10.3 Self-Directed Study
3.10.4 Exercises
Figure 3.1
Figure 3.1
Figure 3.2
Table 3.1
Table 3.1
Table 3.2
Table 3.3
Chapter 4 Conditionals
4.1 Motivating Example
4.2 The if Expression
4.3 Comparisons
4.4 Boolean Logic
4.5 Bigger Expressions
Bit-wise Arithmetic
4.6 End of Chapter Material
4.6.1 Problem-Solving Approach
4.6.2 Summary of Concepts
4.6.3 Self-Directed Study
4.6.4 Exercises
4.6.5 Projects
Table 4.1
Table 4.1
Table 4.2
Table 4.3
Table 4.4
Chapter 5 Functions
5.1 Motivating Example
5.2 Function Refresher
5.3 Making and Using Functions
5.4 Problem Decomposition
5.5 Function Literals
5.6 Non-Functional Functions/Procedures
5.7 type Declarations
5.8 Putting it Together
5.9 End of Chapter Material
5.9.1 Problem-Solving Approach
5.9.2 Summary of Concepts
5.9.3 Self-Directed Study
5.9.4 Exercises
5.9.5 Projects
Figure 5.1
Figure 5.1
Figure 5.2
Chapter 6 Recursion for Iteration
6.1 Basics of Recursion
6.2 Writing Recursion
6.3 User Input
6.4 Abstraction
6.5 Matching
6.6 Putting it Together
6.7 Looking Ahead
6.8 End of Chapter Material
6.8.1 Problem-Solving Approach
6.8.2 Summary of Concepts
6.8.3 Self-Directed Study
6.8.4 Exercises
6.8.5 Projects
Figure 6.1
Figure 6.1
Chapter 7 Arrays and Lists in Scala
7.1 Making Arrays
7.2 Using Arrays
7.3 Lists
7.4 Standard Methods
7.4.1 Basic Methods
7.4.2 Higher-Order Methods
7.4.3 Combinatorial/Iterator Methods
7.5 A World of Types
7.5.1 The Option Type
7.5.2 Parametric Functions
7.5.3 Subtyping
7.6 Variable Length Argument Lists
7.7 Mutability and Aliasing
7.8 Basic Argument Passing
7.9 Pass-By-Name
7.10 Fill and Tabulate
7.11 Complete Grades Script/Software Development
7.12 End of Chapter Material
7.12.1 Problem-Solving Approach
7.12.2 Summary of Concepts
7.12.3 Self-Directed Study
7.12.4 Exercises
7.12.5 Projects
Figure 7.1
Figure 7.1
Figure 7.2
Figure 7.3
Figure 7.4
Figure 7.5
Figure 7.6
Chapter 8 Loops
8.1 while Loop
8.2 do-while Loop
8.3 for Loop
8.3.1 Range Type
8.3.2 yield
8.3.3 if Guards
8.3.4 Multiple Generators
8.3.5 Patterns in for Loops
8.3.6 Variable Declarations
8.4 Multidimensional Arrays
8.5 Testing
8.6 Putting it Together
8.7 End of Chapter Material
8.7.1 Problem-Solving Approach
8.7.2 Summary of Concepts
8.7.3 Self-Directed Study
8.7.4 Exercises
8.7.5 Projects
Chapter 9 Text Files
9.1 I/O Redirection
9.2 Packages and import Statements
9.3 Reading from Files
9.3.1 Iterators
9.3.2 String split Method
9.3.3 Reading from Other Things
9.3.4 Other Options (Java Based)
9.4 Writing to File
9.4.1 Appending to File
9.5 Use Case: Simple Encryption
9.5.1 Command-Line Arguments
9.5.2 Mapping a File
9.5.3 Character Offset
9.5.4 Alphabet Flip
9.5.5 Key Word
9.5.6 Putting it Together
9.5.7 Primes and Real Cryptography
9.6 End of Chapter Material
9.6.1 Summary of Concepts
9.6.2 Self-Directed Study
9.6.3 Exercises
9.6.4 Projects
Chapter 10 Case Classes
10.1 User-Defined Types
10.2 Case Classes
10.2.1 Making Objects
10.2.2 Accessing Elements
10.2.3 Named and Default Arguments (Advanced)
10.2.4 The copy Method
10.2.5 Case Class Patterns
10.3 Mutable Classes
10.4 Putting it Together
10.5 End of Chapter Material
10.5.1 Summary of Concepts
10.5.2 Self-Directed Study
10.5.3 Exercises
10.5.4 Projects
Chapter 11 GUIs
11.1 GUI Libraries and History
11.2 GUI Components
11.2.1 Frames and Windows
11.2.2 Components
11.2.3 Panels and Panes
11.2.4 Menus
11.2.5 Tooltips
11.3 Basic Interactivity
11.3.1 Partial Functions
11.3.2 Publishers and Reactors
11.3.3 Mnemonics
11.4 FileChooser
11.5 Tables
11.5.1 Table Actions
11.5.2 Table Models
11.6 Putting it Together
11.7 End of Chapter Material
11.7.1 Summary of Concepts
11.7.2 Self-Directed Study
11.7.3 Exercises
11.7.4 Projects
Figure 11.1
Figure 11.1
Figure 11.2
Figure 11.3
Chapter 12 Graphics
12.1 Custom-Drawn Panels
12.2 java.awt.Graphics2D
12.2.1 Shapes
12.2.2 Settings
12.2.2.1 Paint
12.2.2.2 Stroke
12.2.2.3 Font
12.2.2.4 Clip
12.2.2.5 Transform
12.2.3 Affine Transforms
12.3 Images
12.3.1 BufferedImage
12.3.2 Reading and Writing Images
12.3.3 Double Buffering
12.3.4 Revisiting TexturePaint
12.4 Other Events
12.4.1 Mouse Events
12.4.2 Keyboard Events
12.5 Animation with Timer
12.6 Putting it Together
12.7 End of Chapter Material
12.7.1 Summary of Concepts
12.7.2 Exercises
12.7.3 Projects
Figure 12.1
Figure 12.1
Figure 12.2
Figure 12.3
Figure 12.4
Figure 12.5
Figure 12.6
Figure 12.7
Chapter 13 Sorting and Searching
13.1 Basic Comparison Sorts
13.1.1 Bubble Sort
13.1.2 Selection Sort (Min/Max)
13.1.3 Insertion Sort
13.1.4 Testing and Verifying Sorts
13.1.5 Sort Visualization
13.1.6 Order Analysis
13.1.7 Shell Sort (Diminishing Gap Sort)
13.2 Searching
13.2.1 Sequential Search (Linear Search)
13.2.2 Binary Search
13.3 Performance and Timing
13.4 Classifying Bugs
13.5 Memory Layout
13.6 Sorting/Searching with case classes
13.7 Putting it Together
13.8 End of Chapter Material
13.8.1 Summary of Concepts
13.8.2 Exercises
13.8.3 Projects
Table 13.1
Table 13.1
Chapter 14 XML
14.1 Description of XML
14.1.1 Tags
14.1.2 Elements
14.1.3 Attributes
14.1.4 Content
14.1.5 Special Characters
14.1.6 Comments
14.1.7 Overall Format
14.1.8 Comparison to Flat File
14.1.8.1 Flexibility in XML
14.2 XML in Scala
14.2.1 Loading XML
14.2.2 Parsing XML
14.2.3 Building XML
14.2.4 Writing XML to File
14.2.5 XML Patterns
14.3 Putting it Together
14.4 End of Chapter Material
14.4.1 Summary of Concepts
14.4.2 Self-Directed Study
14.4.3 Exercises
14.4.4 Projects
Chapter 15 Recursion
15.1 Power of Recursion
15.2 Fibonacci Numbers
15.3 Permutations
15.4 Towers of Hanoi
15.5 Mazes
15.6 Sorts
15.6.1 Divide and Conquer Sorts
15.6.1.1 Merge Sort
15.6.1.2 Quicksort
15.7 Putting it Together
15.8 End of Chapter Material
15.8.1 Summary of Concepts
15.8.2 Exercises
15.8.3 Projects
Figure 15.1
Figure 15.1
Figure 15.2
Part II Object-Orientation, Abstraction, and Data Structures
Chapter 16 Object-Orientation
16.1 Basics of Object-Orientation
16.1.1 Methods and Members
16.1.1.1 Parameters as Members
16.1.1.2 Visibility
16.1.2 this Keyword
16.1.3 Encapsulation/Separating Interface from Implementation
16.1.4 Special Methods
16.1.4.1 Operator Methods
16.1.4.2 Unary Operators
16.1.4.3 Property Assignment Methods
16.1.4.4 The apply Method
16.1.4.5 The update Method
16.1.4.6 Overloading Methods
16.1.4.7 Vector Example
16.1.5 object Declarations
16.1.5.1 Applications
16.1.5.2 Introduction to Companion Objects
16.1.6 Object Decomposition
16.2 Revisiting the API
16.3 Meaning of case classes
16.4 import Options
16.5 End of Chapter Material
16.5.1 Summary of Concepts
16.5.2 Exercises
16.5.3 Projects
Figure 16.1
Figure 16.1
Table 16.1
Table 16.1
Chapter 17 Bigger Programs/New Tools
17.1 Eclipse IDE
17.2 Concurrent Versions System (CVS)
17.2.1 Making the Repository
17.2.2 Set-up in Eclipse
17.2.3 Getting Access on Other Systems
17.2.4 Repository Usage and Rules
17.3 Scaladoc Comments
17.4 End of Chapter Material
17.4.1 Summary of Concepts
17.4.2 Exercises
17.4.3 Projects
Figure 17.1
Figure 17.1
Figure 17.2
Figure 17.3
Figure 17.4
Figure 17.5
Figure 17.6
Figure 17.7
Figure 17.8
Chapter 18 A Project (Drawing Program)
18.1 Software Development Stages
18.2 Analysis
18.3 Design
18.4 Making Packages
18.5 Project Analysis and Design
18.6 Implementing the GUI
18.7 End of Chapter Material
18.7.1 Summary of Concepts
18.7.2 Exercises
18.7.3 Projects
Figure 18.1
Figure 18.1
Figure 18.2
Figure 18.3
Figure 18.4
Figure 18.5
Chapter 19 Abstraction and Polymorphism
19.1 Polymorphism
19.2 Inclusion Polymorphism (Inheritance and Subtyping)
19.2.1 private Visibility and Inheritance
19.2.2 Protected Visibility
19.2.3 Calling Methods on the Supertype
19.2.4 Anonymous Classes
19.2.5 Abstract Classes
19.2.6 traits
19.2.7 final
19.2.8 Method Resolution
19.2.9 Inheriting from Function Types
19.3 Inheritance in the Project
19.3.1 Drawables
19.3.2 Integration with Drawing
19.4 Parametric Polymorphism
19.4.1 Parametric Types
19.4.2 Parametric Functions and Methods
19.4.3 Type Bounds
19.5 End of Chapter Material
19.5.1 Summary of Concepts
19.5.2 Exercises
19.5.3 Projects
Figure 19.1
Figure 19.1
Figure 19.2
Figure 19.3
Figure 19.4
Figure 19.5
Figure 19.6
Chapter 20 Other Collection Types
20.1 The scala.collection Packages
20.1.1 scala.collection.immutable
20.1.2 scala.collection.mutable
20.2 Sets
20.2.1 Running Through Sets
20.2.2 Mutable vs. Immutable
20.2.3 Using a Set
20.3 Maps
20.3.1 Looping Through a Map
20.3.2 Using Maps
20.4 Buffers
20.5 Collections as Functions
20.6 Project Integration
20.6.1 Commands
20.6.2 Adding Drawables
20.7 End of Chapter Material
20.7.1 Summary of Concepts
20.7.2 Exercises
20.7.3 Projects
Figure 20.1
Figure 20.1
Figure 20.2
Figure 20.3
Chapter 21 Multithreading and Concurrency
21.1 The Multicore Future
21.2 Basic Threads
21.2.1 Problems with Threads
21.2.1.1 Race Conditions
21.2.1.2 Deadlock
21.2.2 Synchronization
21.2.3 Wait/Notify
21.2.4 Other Thread Methods
21.3 Concurrency Library
21.3.1 Executors and Executor Services
21.3.2 Callable and Futures
21.3.3 Parallel Data Structures
21.3.3.1 Shared Barriers
21.3.3.2 The Exchange
21.3.3.3 Assembly Line
21.3.3.4 Ticketed Passengers
21.3.3.5 Other Threadsafe Types
21.3.4 Atomic (java.util.concurrent.atomic)
21.3.5 Locks (java.util.concurrent.locks)
21.4 Parallel Collections
21.5 Introduction to Scala Actors
21.6 Multithreaded Mandelbrot (Project Integration)
21.7 Multithreading in GUIs
21.8 Animated Bouncing Balls (Project Integration)
21.9 End of Chapter Material
21.9.1 Summary of Concepts
21.9.2 Exercises
21.9.3 Projects
Figure 21.1
Figure 21.1
Figure 21.2
Figure 21.3
Chapter 22 Stream I/O
22.1 The java.io Package
22.2 Streams for Files
22.3 Exceptions
22.3.1 try-catch-finally
22.3.2 Effect of Exceptions
22.3.3 Loan Pattern
22.4 Decorating Streams
22.4.1 Buffering
22.4.2 Binary Data
22.4.3 Serialization
22.4.3.1 Binary Serialization
22.4.3.2 XML Serialization
22.5 Saving Drawings (Project Integration)
22.6 End of Chapter Material
22.6.1 Summary of Concepts
22.6.2 Exercises
22.6.3 Projects
Chapter 23 Networking
23.1 TCP and UDP
23.2 Sockets
23.2.1 TCP Sockets
23.2.2 UDP Sockets
23.2.3 Streams from Sockets
23.3 URLs
23.4 Remote Method Invocation (RMI)
23.5 Collaborative Drawing (Project Integration)
23.6 End of Chapter Material
23.6.1 Summary of Concepts
23.6.2 Exercises
23.6.3 Projects
Figure 23.1
Figure 23.1
Figure 23.2
Figure 23.3
Chapter 24 Stacks and Queues
24.1 Abstract Data Types (ADTs)
24.2 Operations on Stacks and Queues
24.3 Real Meaning of O
24.4 O(1) Requirement
24.5 Array-Based Stack
24.6 Array-Based Queue
24.7 Unit Tests
24.7.1 Setup
24.7.2 Writing Tests
24.7.3 Test Suites
24.7.4 Test-Driven Development
24.8 RPN Calculator
24.9 End of Chapter Material
24.9.1 Summary of Concepts
24.9.2 Exercises
24.9.3 Projects
Figure 24.1
Figure 24.1
Figure 24.2
Figure 24.3
Figure 24.4
Figure 24.5
Chapter 25 Linked Lists
25.1 The List/Seq ADT
25.2 Nature of Arrays
25.3 Nature of Linked Lists
25.4 Mutable Singly-Linked List
25.4.1 Implementing mutable.Buffer
25.4.2 Iterators
25.5 Mutable Doubly-Linked List
25.6 Immutable Singly-Linked List
25.7 Linked List-Based Stacks and Queues
25.7.1 Linked List-Based Stack
25.7.2 Linked List-Based Queue
25.8 End of Chapter Material
25.8.1 Summary of Concepts
25.8.2 Exercises
25.8.3 Projects
Figure 25.1
Figure 25.1
Chapter 26 Priority Queues
26.1 Two Approaches
26.1.1 Searching by Priority
26.1.2 Sorted Linked List
26.1.3 Problems with Arrays
26.2 Project Integration: Discrete Event Simulation
26.2.1 Cell Splitting
26.2.2 Collision Handling
26.3 End of Chapter Material
26.3.1 Summary of Concepts
26.3.2 Exercises
26.3.3 Projects
Figure 26.1
Figure 26.1
Chapter 27 Refactoring
27.1 Smells
27.2 Refactorings
27.2.1 Built-in Refactoring Methods
27.2.2 Introduce Null Object
27.2.3 Add and Remove Parameter
27.2.4 Cures for Switch Statements
27.2.5 Consolidate Conditional Expression
27.2.6 Convert Procedural Design to Objects
27.2.7 Encapsulate Collection
27.2.8 Push Down or Pull Up Field or Method
27.2.9 Substitute Algorithm
27.3 End of Chapter Material
27.3.1 Summary of Concepts
27.3.2 Exercises
27.3.3 Projects
Chapter 28 Recursion
28.1 Refresher
28.2 Project Integration: A Maze
28.2.1 Revisiting the Basic Approach
28.2.2 Graphical Editing
28.2.3 Optimizing the Maze
28.3 Graph Traversals
28.4 Divide and Conquer
28.4.1 Merge Sort
28.4.2 Quicksort
28.4.3 Formula Parser
28.5 End of Chapter Material
28.5.1 Summary of Concepts
28.5.2 Exercises
28.5.3 Projects
Chapter 29 Trees
29.1 General Trees
29.1.1 Implementations
29.1.2 Traversals
29.2 Project Integration: Formula Parsing
29.2.1 Formula Tree Traversals and In-order Traversal
29.3 Binary Search Trees: Binary Trees as Maps
29.3.1 Order Analysis
29.3.2 Immutable BSTs
29.4 End of Chapter Material
29.4.1 Summary of Concepts
29.4.2 Exercises
29.4.3 Projects
Figure 29.1
Figure 29.1
Figure 29.2
Figure 29.3
Figure 29.4
Figure 29.5
Figure 29.6
Chapter 30 Regular Expressions and Context-Free Parsers
30.1 Chomsky Grammars
30.1.1 Regular Grammars
30.1.2 Context-Free Grammars
30.1.3 Context-Sensitive Grammars
30.1.4 Recursively Enumerable Grammars
30.2 Regular Expressions
30.2.1 Characters and Character Classes
30.2.2 Logical Operators and Capturing Groups
30.2.3 Greedy Quantifiers
30.2.4 Boundary Requirements
30.2.5 Using Regular Expressions in Code
30.2.6 Drawback of Regular Expressions
30.3 Context-Free Parsers
30.3.1 Default Output
30.3.2 Specified Output
30.4 Project Integration
30.5 End of Chapter Material
30.5.1 Summary of Concepts
30.5.2 Exercises
30.5.3 Projects
Chapter 31 Spatial Trees
31.1 Spatial Data and Grids
31.2 Quadtrees and Octrees
31.3 kD-Trees
31.4 Efficient Bouncing Balls
31.5 End of Chapter Material
31.5.1 Summary of Concepts
31.5.2 Exercises
31.5.3 Projects
Figure 31.1
Figure 31.1
Figure 31.2
Figure 31.3
Chapter 32 Binary Heaps
32.1 Binary Heaps
32.1.1 Binary Heaps as Arrays
32.2 Heaps as Priority Queues
32.3 Heapsort
32.4 End of Chapter Material
32.4.1 Summary of Concepts
32.4.2 Exercises
32.4.3 Projects
Figure 32.1
Figure 32.1
Figure 32.2
Figure 32.3
Figure 32.4
Figure 32.5
Chapter 33 Direct Access Binary Files
33.1 Random Access Files
33.1.1 Fixed Record Length
33.1.2 Indexed Variable Record Length
33.2 Linked Structures in Files
33.3 End of Chapter Material
33.3.1 Summary of Concepts
33.3.2 Exercises
33.3.3 Projects
Figure 33.1
Figure 33.1
Figure 33.2
Figure 33.3
Table 33.1
Table 33.1
Chapter 34 Actors
34.1 Actor Model
34.2 scala.actors Package
34.2.1 The receive Method and Messages
34.2.2 react, loop, and loopWhile
34.3 Circuit Simulation
34.4 End of Chapter Material
34.4.1 Summary of Concepts
34.4.2 Exercises
34.4.3 Projects
Figure 34.1
Figure 34.1
Figure 34.2
Chapter 35 Augmenting Trees
35.1 Augmentation of Trees
35.2 Balanced BSTs
35.2.1 Rotations
35.2.2 Implementation
35.3 Order-Statistic Trees: Trees as Sequences
35.4 Augmented Spatial Trees
35.5 End of Chapter Material
35.5.1 Summary of Concepts
35.5.2 Exercises
35.5.3 Projects
Figure 35.1
Figure 35.1
Figure 35.2
Figure 35.3
Chapter 36 Wrapping Up
36.1 What You Have Learned
36.2 The Possibilities/A Pet Project
36.2.1 General 2-D Application
36.2.2 3-D Application
36.2.3 Mobile
36.2.4 Web
36.2.5 GPGPU
36.2.6 AI, NLP, and Machine Learning
36.2.7 Open-Source and More
36.3 End of Chapter Material
36.3.1 Exercises
36.3.2 Projects
Appendix A Quick Preview of Java
A.1 Hello World
A.2 Arrays, Primitives, and More
A.3 File Names and Interfaces
A.4 Constructors and @Override
A.5 Generics and Polymorphism
A.6 Lacking Functional Aspects
A.7 Much More
Appendix B Advanced Scala Concepts
B.1 abstract type Members
B.2 Enumerations
B.3 implicits
B.3.1 Basic implict Converstions
B.3.2 Rules and Limits on implicits
B.3.3 implicit Parameters
B.3.4 The Meaning of <%
B.4 sealed classes
B.5 Covariant, Contravariant, and Invariant Types
B.6 Extractors
B.6.1 unapply
B.6.2 unapplySeq
B.7 lazy Member Data
B.8 scala.collection.immutable.Stream
B.9 Nested Types
B.10 Self Types
B.11 Making Executable JAR Files
Appendix C Glossary
Bibliography
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
Preface
Next
Next Chapter
Part I Introductory Concepts
Preliminaries
Acknowledgments
Preface
To the Student
Using this Book
Book Website
To the Instructor
Using this Book
Figure
Figure 1
Part I Introductory Concepts
Chapter 1 Basics of Computers, Computing, and Programming
1.1 History
1.2 Hardware
1.3 Software
1.4 Nature of Programming
1.5 Programming Paradigms
1.5.1 Imperative Programming
1.5.2 Functional Programming
1.5.3 Object-Oriented Programming
1.5.4 Logic Programming
1.5.5 Nature of Scala
1.6 End of Chapter Material
1.6.1 Summary of Concepts
1.6.2 Exercises
1.6.3 Projects
Figure
Figure 1.1
Chapter 2 Getting to Know the Tools
2.1 Unix/Linux (includes Mac OS X)
2.1.1 Command-Line
2.1.1.1 Files and Directories
2.1.1.2 Aside
2.1.1.3 Helpful Tips
2.1.1.4 Permissions
2.1.1.5 Compression/Archiving
2.1.1.6 Remote
2.1.1.7 Other Commands
2.1.2 I/O Redirection
2.1.3 Text Editors (vi/vim)
2.2 Windows
2.2.1 Command-Line
2.2.1.1 Files and Directories
2.2.2 Text Editors
2.2.2.1 Edit
2.2.2.2 Notepad
2.2.2.3 Others
2.2.3 Other Commands
2.3 Scala Tools
2.4 End of Chapter Material
2.4.1 Summary of Concepts
2.4.2 Exercises
Figure
Figure 2.1
Figure 2.2
Figure 2.3
Figure 2.4
Chapter 3 Scala Basics
3.1 Expressions, Types, and Basic Math
3.2 Objects and Methods
3.3 Other Basic Types
3.4 Back to the Numbers
3.4.1 Binary Arithmetic
3.4.2 Negative Numbers in Binary
3.4.3 Other Integer Types
3.4.4 Octal and Hexadecimal
3.4.5 Non-Integer Numbers
3.5 The math Object
3.6 Details of Char and String
3.7 Naming Values and Variables
3.8 Sequential Execution
3.8.1 Comments
3.9 A Tip for Learning to Program
3.10 End of Chapter Material
3.10.1 Problem-Solving Approach
3.10.2 Summary of Concepts
3.10.3 Self-Directed Study
3.10.4 Exercises
Figures
Figure 3.1
Figure 3.2
Tables
Table 3.1
Table 3.2
Table 3.3
Chapter 4 Conditionals
4.1 Motivating Example
4.2 The if Expression
4.3 Comparisons
4.4 Boolean Logic
4.5 Bigger Expressions
Bit-wise Arithmetic
4.6 End of Chapter Material
4.6.1 Problem-Solving Approach
4.6.2 Summary of Concepts
4.6.3 Self-Directed Study
4.6.4 Exercises
4.6.5 Projects
Tables
Table 4.1
Table 4.2
Table 4.3
Table 4.4
Chapter 5 Functions
5.1 Motivating Example
5.2 Function Refresher
5.3 Making and Using Functions
5.4 Problem Decomposition
5.5 Function Literals
5.6 Non-Functional Functions/Procedures
5.7 type Declarations
5.8 Putting it Together
5.9 End of Chapter Material
5.9.1 Problem-Solving Approach
5.9.2 Summary of Concepts
5.9.3 Self-Directed Study
5.9.4 Exercises
5.9.5 Projects
Figures
Figure 5.1
Figure 5.2
Chapter 6 Recursion for Iteration
6.1 Basics of Recursion
6.2 Writing Recursion
6.3 User Input
6.4 Abstraction
6.5 Matching
6.6 Putting it Together
6.7 Looking Ahead
6.8 End of Chapter Material
6.8.1 Problem-Solving Approach
6.8.2 Summary of Concepts
6.8.3 Self-Directed Study
6.8.4 Exercises
6.8.5 Projects
Figure
Figure 6.1
Chapter 7 Arrays and Lists in Scala
7.1 Making Arrays
7.2 Using Arrays
7.3 Lists
7.4 Standard Methods
7.4.1 Basic Methods
7.4.2 Higher-Order Methods
7.4.3 Combinatorial/Iterator Methods
7.5 A World of Types
7.5.1 The Option Type
7.5.2 Parametric Functions
7.5.3 Subtyping
7.6 Variable Length Argument Lists
7.7 Mutability and Aliasing
7.8 Basic Argument Passing
7.9 Pass-By-Name
7.10 Fill and Tabulate
7.11 Complete Grades Script/Software Development
7.12 End of Chapter Material
7.12.1 Problem-Solving Approach
7.12.2 Summary of Concepts
7.12.3 Self-Directed Study
7.12.4 Exercises
7.12.5 Projects
Figures
Figure 7.1
Figure 7.2
Figure 7.3
Figure 7.4
Figure 7.5
Figure 7.6
Chapter 8 Loops
8.1
while
Loop
8.2
do-while
Loop
8.3
for
Loop
8.3.1 Range Type
8.3.2
yield
8.3.3
if
Guards
8.3.4 Multiple Generators
8.3.5 Patterns in
for
Loops
8.3.6 Variable Declarations
8.4 Multidimensional Arrays
8.5 Testing
8.6 Putting it Together
8.7 End of Chapter Material
8.7.1 Problem-Solving Approach
8.7.2 Summary of Concepts
8.7.3 Self-Directed Study
8.7.4 Exercises
8.7.5 Projects
Chapter 9 Text Files
9.1 I/O Redirection
9.2 Packages and
import
Statements
9.3 Reading from Files
9.3.1 Iterators
9.3.2 String
split
Method
9.3.3 Reading from Other Things
9.3.4 Other Options (Java Based)
9.4 Writing to File
9.4.1 Appending to File
9.5 Use Case: Simple Encryption
9.5.1 Command-Line Arguments
9.5.2 Mapping a File
9.5.3 Character Offset
9.5.4 Alphabet Flip
9.5.5 Key Word
9.5.6 Putting it Together
9.5.7 Primes and Real Cryptography
9.6 End of Chapter Material
9.6.1 Summary of Concepts
9.6.2 Self-Directed Study
9.6.3 Exercises
9.6.4 Projects
Chapter 10 Case Classes
10.1 User-Defined Types
10.2 Case Classes
10.2.1 Making Objects
10.2.2 Accessing Elements
10.2.3 Named and Default Arguments (Advanced)
10.2.4 The
copy
Method
10.2.5 Case Class Patterns
10.3 Mutable Classes
10.4 Putting it Together
10.5 End of Chapter Material
10.5.1 Summary of Concepts
10.5.2 Self-Directed Study
10.5.3 Exercises
10.5.4 Projects
Chapter 11 GUIs
11.1 GUI Libraries and History
11.2 GUI Components
11.2.1 Frames and Windows
11.2.2 Components
11.2.3 Panels and Panes
11.2.4 Menus
11.2.5 Tooltips
11.3 Basic Interactivity
11.3.1 Partial Functions
11.3.2 Publishers and Reactors
11.3.3 Mnemonics
11.4
FileChooser
11.5 Tables
11.5.1 Table Actions
11.5.2 Table Models
11.6 Putting it Together
11.7 End of Chapter Material
11.7.1 Summary of Concepts
11.7.2 Self-Directed Study
11.7.3 Exercises
11.7.4 Projects
Figures
Figure 11.1
Figure 11.2
Figure 11.3
Chapter 12 Graphics
12.1 Custom-Drawn Panels
12.2
java.awt.Graphics2D
12.2.1
Shape
s
12.2.2 Settings
12.2.2.1
Paint
12.2.2.2
Stroke
12.2.2.3
Font
12.2.2.4 Clip
12.2.2.5 Transform
12.2.3 Affine Transforms
12.3 Images
12.3.1
BufferedImage
12.3.2 Reading and Writing Images
12.3.3 Double Buffering
12.3.4 Revisiting TexturePaint
12.4 Other Events
12.4.1 Mouse Events
12.4.2 Keyboard Events
12.5 Animation with Timer
12.6 Putting it Together
12.7 End of Chapter Material
12.7.1 Summary of Concepts
12.7.2 Exercises
12.7.3 Projects
Figures
Figure 12.1
Figure 12.2
Figure 12.3
Figure 12.4
Figure 12.5
Figure 12.6
Figure 12.7
Chapter 13 Sorting and Searching
13.1 Basic Comparison Sorts
13.1.1 Bubble Sort
13.1.2 Selection Sort (Min/Max)
13.1.3 Insertion Sort
13.1.4 Testing and Verifying Sorts
13.1.5 Sort Visualization
13.1.6 Order Analysis
13.1.7 Shell Sort (Diminishing Gap Sort)
13.2 Searching
13.2.1 Sequential Search (Linear Search)
13.2.2 Binary Search
13.3 Performance and Timing
13.4 Classifying Bugs
13.5 Memory Layout
13.6 Sorting/Searching with
case class
es
13.7 Putting it Together
13.8 End of Chapter Material
13.8.1 Summary of Concepts
13.8.2 Exercises
13.8.3 Projects
Table
Table 13.1
Chapter 14 XML
14.1 Description of XML
14.1.1 Tags
14.1.2 Elements
14.1.3 Attributes
14.1.4 Content
14.1.5 Special Characters
14.1.6 Comments
14.1.7 Overall Format
14.1.8 Comparison to Flat File
14.1.8.1 Flexibility in XML
14.2 XML in Scala
14.2.1 Loading XML
14.2.2 Parsing XML
14.2.3 Building XML
14.2.4 Writing XML to File
14.2.5 XML Patterns
14.3 Putting it Together
14.4 End of Chapter Material
14.4.1 Summary of Concepts
14.4.2 Self-Directed Study
14.4.3 Exercises
14.4.4 Projects
Chapter 15 Recursion
15.1 Power of Recursion
15.2 Fibonacci Numbers
15.3 Permutations
15.4 Towers of Hanoi
15.5 Mazes
15.6 Sorts
15.6.1 Divide and Conquer Sorts
15.6.1.1 Merge Sort
15.6.1.2 Quicksort
15.7 Putting it Together
15.8 End of Chapter Material
15.8.1 Summary of Concepts
15.8.2 Exercises
15.8.3 Projects
Figures
Figure 15.1
Figure 15.2
Part II Object-Orientation, Abstraction, and Data Structures
Chapter 16 Object-Orientation
16.1 Basics of Object-Orientation
16.1.1 Methods and Members
16.1.1.1 Parameters as Members
16.1.1.2 Visibility
16.1.2
this
Keyword
16.1.3 Encapsulation/Separating Interface from Implementation
16.1.4 Special Methods
16.1.4.1 Operator Methods
16.1.4.2 Unary Operators
16.1.4.3 Property Assignment Methods
16.1.4.4 The
apply
Method
16.1.4.5 The
update
Method
16.1.4.6 Overloading Methods
16.1.4.7 Vector Example
16.1.5
object
Declarations
16.1.5.1 Applications
16.1.5.2 Introduction to Companion Objects
16.1.6 Object Decomposition
16.2 Revisiting the API
16.3 Meaning of
case class
es
16.4
import
Options
16.5 End of Chapter Material
16.5.1 Summary of Concepts
16.5.2 Exercises
16.5.3 Projects
Figure
Figure 16.1
Table
Table 16.1
Chapter 17 Bigger Programs/New Tools
17.1 Eclipse IDE
17.2 Concurrent Versions System (CVS)
17.2.1 Making the Repository
17.2.2 Set-up in Eclipse
17.2.3 Getting Access on Other Systems
17.2.4 Repository Usage and Rules
17.3 Scaladoc Comments
17.4 End of Chapter Material
17.4.1 Summary of Concepts
17.4.2 Exercises
17.4.3 Projects
Figures
Figure 17.1
Figure 17.2
Figure 17.3
Figure 17.4
Figure 17.5
Figure 17.6
Figure 17.7
Figure 17.8
Chapter 18 A Project (Drawing Program)
18.1 Software Development Stages
18.2 Analysis
18.3 Design
18.4 Making Packages
18.5 Project Analysis and Design
18.6 Implementing the GUI
18.7 End of Chapter Material
18.7.1 Summary of Concepts
18.7.2 Exercises
18.7.3 Projects
Figures
Figure 18.1
Figure 18.2
Figure 18.3
Figure 18.4
Figure 18.5
Chapter 19 Abstraction and Polymorphism
19.1 Polymorphism
19.2 Inclusion Polymorphism (Inheritance and Subtyping)
19.2.1 private Visibility and Inheritance
19.2.2 Protected Visibility
19.2.3 Calling Methods on the Supertype
19.2.4 Anonymous Classes
19.2.5 Abstract Classes
19.2.6
traits
19.2.7
final
19.2.8 Method Resolution
19.2.9 Inheriting from Function Types
19.3 Inheritance in the Project
19.3.1 Drawables
19.3.2 Integration with Drawing
19.4 Parametric Polymorphism
19.4.1 Parametric Types
19.4.2 Parametric Functions and Methods
19.4.3 Type Bounds
19.5 End of Chapter Material
19.5.1 Summary of Concepts
19.5.2 Exercises
19.5.3 Projects
Figures
Figure 19.1
Figure 19.2
Figure 19.3
Figure 19.4
Figure 19.5
Figure 19.6
Chapter 20 Other Collection Types
20.1 The scala.collection Packages
20.1.1 scala.collection.immutable
20.1.2 scala.collection.mutable
20.2 Sets
20.2.1 Running Through Sets
20.2.2 Mutable vs. Immutable
20.2.3 Using a Set
20.3 Maps
20.3.1 Looping Through a Map
20.3.2 Using Maps
20.4 Buffers
20.5 Collections as Functions
20.6 Project Integration
20.6.1 Commands
20.6.2 Adding Drawables
20.7 End of Chapter Material
20.7.1 Summary of Concepts
20.7.2 Exercises
20.7.3 Projects
Figures
Figure 20.1
Figure 20.2
Figure 20.3
Chapter 21 Multithreading and Concurrency
21.1 The Multicore Future
21.2 Basic Threads
21.2.1 Problems with Threads
21.2.1.1 Race Conditions
21.2.1.2 Deadlock
21.2.2 Synchronization
21.2.3 Wait/Notify
21.2.4 Other Thread Methods
21.3 Concurrency Library
21.3.1 Executors and Executor Services
21.3.2 Callable and Futures
21.3.3 Parallel Data Structures
21.3.3.1 Shared Barriers
21.3.3.2 The Exchange
21.3.3.3 Assembly Line
21.3.3.4 Ticketed Passengers
21.3.3.5 Other Threadsafe Types
21.3.4 Atomic (
java.util.concurrent.atomic
)
21.3.5 Locks (
java.util.concurrent.locks
)
21.4 Parallel Collections
21.5 Introduction to Scala Actors
21.6 Multithreaded Mandelbrot (Project Integration)
21.7 Multithreading in GUIs
21.8 Animated Bouncing Balls (Project Integration)
21.9 End of Chapter Material
21.9.1 Summary of Concepts
21.9.2 Exercises
21.9.3 Projects
Figures
Figure 21.1
Figure 21.2
Figure 21.3
Chapter 22 Stream I/O
22.1 The
java.io
Package
22.2 Streams for Files
22.3 Exceptions
22.3.1
try-catch-finally
22.3.2 Effect of Exceptions
22.3.3 Loan Pattern
22.4 Decorating Streams
22.4.1 Buffering
22.4.2 Binary Data
22.4.3 Serialization
22.4.3.1 Binary Serialization
22.4.3.2 XML Serialization
22.5 Saving Drawings (Project Integration)
22.6 End of Chapter Material
22.6.1 Summary of Concepts
22.6.2 Exercises
22.6.3 Projects
Chapter 23 Networking
23.1 TCP and UDP
23.2 Sockets
23.2.1 TCP Sockets
23.2.2 UDP Sockets
23.2.3 Streams from Sockets
23.3 URLs
23.4 Remote Method Invocation (RMI)
23.5 Collaborative Drawing (Project Integration)
23.6 End of Chapter Material
23.6.1 Summary of Concepts
23.6.2 Exercises
23.6.3 Projects
Figures
Figure 23.1
Figure 23.2
Figure 23.3
Chapter 24 Stacks and Queues
24.1 Abstract Data Types (ADTs)
24.2 Operations on Stacks and Queues
24.3 Real Meaning of
O
24.4
O
(1) Requirement
24.5 Array-Based Stack
24.6 Array-Based Queue
24.7 Unit Tests
24.7.1 Setup
24.7.2 Writing Tests
24.7.3 Test Suites
24.7.4 Test-Driven Development
24.8 RPN Calculator
24.9 End of Chapter Material
24.9.1 Summary of Concepts
24.9.2 Exercises
24.9.3 Projects
Figures
Figure 24.1
Figure 24.2
Figure 24.3
Figure 24.4
Figure 24.5
Chapter 25 Linked Lists
25.1 The List/Seq ADT
25.2 Nature of Arrays
25.3 Nature of Linked Lists
25.4 Mutable Singly-Linked List
25.4.1 Implementing
mutable.Buffer
25.4.2 Iterators
25.5 Mutable Doubly-Linked List
25.6 Immutable Singly-Linked List
25.7 Linked List-Based Stacks and Queues
25.7.1 Linked List-Based Stack
25.7.2 Linked List-Based Queue
25.8 End of Chapter Material
25.8.1 Summary of Concepts
25.8.2 Exercises
25.8.3 Projects
Figure
Figure 25.1
Chapter 26 Priority Queues
26.1 Two Approaches
26.1.1 Searching by Priority
26.1.2 Sorted Linked List
26.1.3 Problems with Arrays
26.2 Project Integration: Discrete Event Simulation
26.2.1 Cell Splitting
26.2.2 Collision Handling
26.3 End of Chapter Material
26.3.1 Summary of Concepts
26.3.2 Exercises
26.3.3 Projects
Figure
Figure 26.1
Chapter 27 Refactoring
27.1 Smells
27.2 Refactorings
27.2.1 Built-in Refactoring Methods
27.2.2 Introduce Null Object
27.2.3 Add and Remove Parameter
27.2.4 Cures for Switch Statements
27.2.5 Consolidate Conditional Expression
27.2.6 Convert Procedural Design to Objects
27.2.7 Encapsulate Collection
27.2.8 Push Down or Pull Up Field or Method
27.2.9 Substitute Algorithm
27.3 End of Chapter Material
27.3.1 Summary of Concepts
27.3.2 Exercises
27.3.3 Projects
Chapter 28 Recursion
28.1 Refresher
28.2 Project Integration: A Maze
28.2.1 Revisiting the Basic Approach
28.2.2 Graphical Editing
28.2.3 Optimizing the Maze
28.3 Graph Traversals
28.4 Divide and Conquer
28.4.1 Merge Sort
28.4.2 Quicksort
28.4.3 Formula Parser
28.5 End of Chapter Material
28.5.1 Summary of Concepts
28.5.2 Exercises
28.5.3 Projects
Chapter 29 Trees
29.1 General Trees
29.1.1 Implementations
29.1.2 Traversals
29.2 Project Integration: Formula Parsing
29.2.1 Formula Tree Traversals and In-order Traversal
29.3 Binary Search Trees: Binary Trees as Maps
29.3.1 Order Analysis
29.3.2 Immutable BSTs
29.4 End of Chapter Material
29.4.1 Summary of Concepts
29.4.2 Exercises
29.4.3 Projects
Figures
Figure 29.1
Figure 29.2
Figure 29.3
Figure 29.4
Figure 29.5
Figure 29.6
Chapter 30 Regular Expressions and Context-Free Parsers
30.1 Chomsky Grammars
30.1.1 Regular Grammars
30.1.2 Context-Free Grammars
30.1.3 Context-Sensitive Grammars
30.1.4 Recursively Enumerable Grammars
30.2 Regular Expressions
30.2.1 Characters and Character Classes
30.2.2 Logical Operators and Capturing Groups
30.2.3 Greedy Quantifiers
30.2.4 Boundary Requirements
30.2.5 Using Regular Expressions in Code
30.2.6 Drawback of Regular Expressions
30.3 Context-Free Parsers
30.3.1 Default Output
30.3.2 Specified Output
30.4 Project Integration
30.5 End of Chapter Material
30.5.1 Summary of Concepts
30.5.2 Exercises
30.5.3 Projects
Chapter 31 Spatial Trees
31.1 Spatial Data and Grids
31.2 Quadtrees and Octrees
31.3 kD-Trees
31.4 Efficient Bouncing Balls
31.5 End of Chapter Material
31.5.1 Summary of Concepts
31.5.2 Exercises
31.5.3 Projects
Figures
Figure 31.1
Figure 31.2
Figure 31.3
Chapter 32 Binary Heaps
32.1 Binary Heaps
32.1.1 Binary Heaps as Arrays
32.2 Heaps as Priority Queues
32.3 Heapsort
32.4 End of Chapter Material
32.4.1 Summary of Concepts
32.4.2 Exercises
32.4.3 Projects
Figures
Figure 32.1
Figure 32.2
Figure 32.3
Figure 32.4
Figure 32.5
Chapter 33 Direct Access Binary Files
33.1 Random Access Files
33.1.1 Fixed Record Length
33.1.2 Indexed Variable Record Length
33.2 Linked Structures in Files
33.3 End of Chapter Material
33.3.1 Summary of Concepts
33.3.2 Exercises
33.3.3 Projects
Figures
Figure 33.1
Figure 33.2
Figure 33.3
Table
Table 33.1
Chapter 34 Actors
34.1 Actor Model
34.2
scala.actors
Package
34.2.1 The receive Method and Messages
34.2.2
react, loop
, and
loopWhile
34.3 Circuit Simulation
34.4 End of Chapter Material
34.4.1 Summary of Concepts
34.4.2 Exercises
34.4.3 Projects
Figures
Figure 34.1
Figure 34.2
Chapter 35 Augmenting Trees
35.1 Augmentation of Trees
35.2 Balanced BSTs
35.2.1 Rotations
35.2.2 Implementation
35.3 Order-Statistic Trees: Trees as Sequences
35.4 Augmented Spatial Trees
35.5 End of Chapter Material
35.5.1 Summary of Concepts
35.5.2 Exercises
35.5.3 Projects
Figures
Figure 35.1
Figure 35.2
Figure 35.3
Chapter 36 Wrapping Up
36.1 What You Have Learned
36.2 The Possibilities/A Pet Project
36.2.1 General 2-D Application
36.2.2 3-D Application
36.2.3 Mobile
36.2.4 Web
36.2.5 GPGPU
36.2.6 AI, NLP, and Machine Learning
36.2.7 Open-Source and More
36.3 End of Chapter Material
36.3.1 Exercises
36.3.2 Projects
Appendix A Quick Preview of Java
A.1 Hello World
A.2 Arrays, Primitives, and More
A.3 File Names and Interfaces
A.4 Constructors and
@Override
A.5 Generics and Polymorphism
A.6 Lacking Functional Aspects
A.7 Much More
Appendix B Advanced Scala Concepts
B.1
abstract
type Members
B.2 Enumerations
B.3
implicit
s
B.3.1 Basic
implict
Converstions
B.3.2 Rules and Limits on implicits
B.3.3
implicit
Parameters
B.3.4 The Meaning of
<%
B.4
sealed class
es
B.5 Covariant, Contravariant, and Invariant Types
B.6 Extractors
B.6.1
unapply
B.6.2
unapplySeq
B.7
lazy
Member Data
B.8
scala.collection.immutable.Stream
B.9 Nested Types
B.10 Self Types
B.11 Making Executable JAR Files
Appendix C Glossary
Bibliography
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset