大家注意了~,checked_iterator影响performance

chenyu2202863 2010-07-19 01:26:24
在VC2005以上环境下,用M$的STL库时,涉及到容器和迭代器的代码,如果特别在意Performance,需要使用_SECURE_SCL开关,避免内置的checked_iterator所带来的影响~

因为M$并没有在release模式下关闭此_SECURE_SCL开关,具体信息可以看:
http://msdn.microsoft.com/en-us/library/aa985965(VS.80).aspx
http://askldjd.wordpress.com/tag/checked-iterator/
http://channel9.msdn.com/shows/Going+Deep/STL-Iterator-Debugging-and-Secure-SCL/

如果希望再release模式下避免无谓的牺牲,具体做法就是在包含STL任意头文件之前使用

#ifndef _DEBUG
#define _SECURE_SCL 0
#endif


C++一直提倡:不要为不必要的东西而买单!

纯属散分,欢迎讨论~
...全文
187 28 打赏 收藏 转发到动态 举报
写回复
用AI写文章
28 条回复
切换为时间正序
请发表友善的回复…
发表回复
勇-子 2010-07-20
  • 打赏
  • 举报
回复
前来学习!
nbabest23 2010-07-20
  • 打赏
  • 举报
回复
学习!
wang23432 2010-07-20
  • 打赏
  • 举报
回复
学习了,谢谢
wlc1986 2010-07-20
  • 打赏
  • 举报
回复
厉害,还真不知道有这么回事。调试版都过关了,那应该问题不大,关掉这功能,确实不错。
BlueMap 2010-07-20
  • 打赏
  • 举报
回复
很少用,接分。。。
jameshooo 2010-07-19
  • 打赏
  • 举报
回复
很少用STL,接分吧
sevencat 2010-07-19
  • 打赏
  • 举报
回复
这个很恶心的,有时候能非常强大的降低你的程序的速度。
webcq1999 2010-07-19
  • 打赏
  • 举报
回复
谢谢,接分。
fishion 2010-07-19
  • 打赏
  • 举报
回复
不知道
sunlin7 2010-07-19
  • 打赏
  • 举报
回复
还真的没有留意到呢~~
苏克贝塔03 2010-07-19
  • 打赏
  • 举报
回复
都下班了,接分的不多。。。
oyljerry 2010-07-19
  • 打赏
  • 举报
回复
^_^,多谢分享
woai1075 2010-07-19
  • 打赏
  • 举报
回复
学习 接分
adamwyb 2010-07-19
  • 打赏
  • 举报
回复
学习接分
icefairy 2010-07-19
  • 打赏
  • 举报
回复
jf 学习了
chenyu2202863 2010-07-19
  • 打赏
  • 举报
回复
看来放错了坛子~
chenyu2202863 2010-07-19
  • 打赏
  • 举报
回复
三分贴,没人要?
Formular1 2010-07-19
  • 打赏
  • 举报
回复
不用stl
dulvtianya 2010-07-19
  • 打赏
  • 举报
回复
学习并接分
stonewater 2010-07-19
  • 打赏
  • 举报
回复
学习了
加载更多回复(7)
一本不错的C#书,希望对您有帮助,本书目录: C# 3.0 Unleashed 1 Table of Contents 6 Introduction 30 Why This Book Is for You 31 Organization and Goals 32 Part 1 Learning C# Basics 36 1 Introducing the .NET Platform 38 What Is .NET? 38 The Common Language Runtime (CLR) 40 The .NET Framework Class Library (FCL) 43 C# and Other .NET Languages 45 The Common Type System (CTS) 46 The Common Language Specification (CLS) 46 Summary 46 2 Getting Started with C# and Visual Studio 2008 48 Writing a Simple C# Program 48 Creating a Visual Studio 2008 (VS2008) Project 52 Commenting Code 61 Identifiers and Keywords 64 Convention and Style 66 Variables and Types 67 Definite Assignment 73 Interacting with Programs 74 Summary 77 3 Writing C# Expressions and Statements 78 C# Operators 78 Statements 91 Blocks and Scope 92 Labels 92 Operator Precedence and Associativity 93 Selection and Looping Statements 94 Summary 106 4 Understanding Reference Types and Value Types 108 A Quick Introduction to Reference Types and Value Types 108 The Unified Type System 109 Reference Type and Value Type Memory Allocation 114 Reference Type and Value Type Assignment 117 More Differences Between Reference Types and Value Types 121 C# and .NET Framework Types 123 Nullable Types 131 Summary 132 5 Manipulating Strings 134 The C# String Type 134 The StringBuilder Class 151 Regular Expressions 153 Summary 158 6 Arrays and Enums 160 Arrays 160 The System.Array Class 166 Using Enum Types 168 The System.Enum struct 171 Summary 174 7 Debugging Applications with Visual Studio 2008 176 Stepping Through Code 176 Summary 188 Part 2 Object-Oriented Programming with C# 190 8 Designing Objects 192 Object Members 192 Instance and Static Members 193 Fields 194 Methods 195 Properties 196 Indexers 198 Reviewing Where Partial Types Fit In 199 Static Classes 200 The System.Object Class 201 Summary 204 9 Designing Object-Oriented Programs 206 Inheritance 207 Encapsulating Object Internals 213 Polymorphism 219 Summary 229 10 Coding Methods and Custom Operators 230 Methods 231 Overloading Methods 239 Overloading Operators 242 Conversions and Conversion Operator Overloads 247 Partial Methods 256 Extension Methods 257 Summary 259 11 Error and Exception Handling 260 Why Exception Handling? 261 Exception Handler Syntax: The Basic try/catch Block 261 Ensuring Resource Cleanup with finally Blocks 263 Handling Exceptions 264 Designing Your Own Exceptions 272 checked and unchecked Statements 274 Summary 277 12 Event-Based Programming with Delegates and Events 278 Exposing Delegates 279 Implementing Delegate Inference 285 Assigning Anonymous Methods 285 Coding Events 287 Summary 300 13 Naming and Organizing Types with Namespaces 302 Why Namespaces? 303 Namespace Directives 304 Creating Namespaces 307 Namespace Members 310 Scope and Visibility 311 Namespace Alias Qualifiers 312 Extern Namespaces Alias 313 Summary 315 14 Implementing Abstract Classes and Interfaces 316 Abstract Classes 317 Abstract Class and Interface Differences 319 Implementing Interfaces 320 Defining Interface Types 320 Implicit Implementation 322 Explicit Implementation 333 Interface Mapping 339 Interface Inheritance 341 Summary 344 Part 3 Applying Advanced C# Language Features 346 15 Managing Object Lifetime 348 Object Initialization 349 Object Initializers 355 Object Finalization 356 Automatic Memory Management 357 Proper Resource Cleanup 360 Interacting with the Garbage Collector 364 Summary 366 16 Declaring Attributes and Examining Code with Reflection 368 Using Attributes 369 Using Attribute Parameters 371 Attribute Targets 373 Creating Your Own Attributes 374 Using Reflection 378 Reflecting on Attributes 385 Summary 392 17 Parameterizing Type with Generics and Writing Iterators 394 Nongeneric Collections 395 Understanding the Benefits of Generics 395 Building Generic Types 401 Implementing Iterators 417 Summary 425 18 Using Lambda Expressions and Expression Trees 426 Lambda Expressions 427 Expression Trees 433 Summary 435 Part 4 Learning LINQ and .NET Data Access 436 19 Accessing Data with LINQ 438 LINQ to Objects 439 Querying Relational Data with LINQ to SQL 443 Standard Query Operators 456 Summary 468 20 Managing Data with ADO.NET 470 ADO.NET Architecture 470 Making Connections 474 Viewing Data 476 Manipulating Data 479 Calling Stored Procedures 481 Working with Disconnected Data 482 LINQ to DataSet 487 Summary 488 21 Manipulating XML Data 490 Streaming XML Data 491 Writing XML 491 Reading XML 494 Working with the XML DOM 495 Easier Manipulation with LINQ to XML 497 Summary 502 22 Creating Data Abstractions with the ADO.NET Entity Framework 504 An Overview of Entities 505 Starting the Entity Data Model in VS2008 505 Querying Entities with Entity SQL 509 Creating Custom Entities 511 Coding with LINQ to Entities 515 Summary 518 23 Working with Data in the Cloud with ADO.NET Data Services 520 Adding ADO.NET Data Services to Your Project 521 Accessing ADO.NET Data Services via HTTP URIs 522 Writing Code with the ADO.NET Data Services Client Library 528 Summary 533 Part 5 Building Desktop User Interfaces 534 24 Taking Console Applications to the Limit 536 Introducing the PasswordGenerator Console Application 537 Interacting with the User 537 Handling Command-Line Input 539 Adding Color and Positioning to Consoles 540 Summary 543 25 Writing Windows Forms Applications 544 Windows Forms Fundamentals 545 VS2008 Support for Windows Forms 548 Using Windows Forms Controls 557 MenuStrip, StatusStrip, and ToolStrip Controls 560 Data Grids and Data Binding 562 GDI+ Essentials 565 Additional Windows and Dialogs 568 Summary 574 26 Creating Windows Presentation Foundation (WPF) Applications 576 Just Enough XAML 577 Managing Layout 580 WPF Controls 589 Event Handling 602 Data Binding 603 Using Styles 607 Summary 609 Part 6 Designing Web User Interfaces 610 27 Building Web Applications with ASP.NET 612 The Web Application Model 612 Starting an ASP.NET Project with VS2008 615 A Lap Around an ASP.NET Page 617 Controls 622 State Management 625 Navigation 632 Theming a Site 638 Securing a Website 641 Data Binding 643 Summary 646 28 Adding Interactivity to Your Web Apps with ASP.NET AJAX 648 What Is AJAX? 648 Setting Up an ASP.NET AJAX Site 649 The AJAX Page Life Cycle 650 Loading Custom Script Libraries 652 ASP.NET AJAX Controls 654 Accessing Controls via JavaScript 657 Calling Web Services with ASP.NET AJAX 664 Summary 669 29 Crafting Rich Web Applications with Silverlight 670 What Makes Silverlight Tick? 670 Starting a Silverlight Project in VS2008 671 Handling Silverlight Events with C# 677 Playing Media 681 Animating UI Elements 684 Summary 686 Part 7 Communicating with .NET Technologies 688 30 Using .NET Network Communications Technologies 690 Implementing Sockets 690 Working with HTTP 698 Performing FTP File Transfers 700 Sending SMTP Mail 704 Summary 705 31 Building Windows Service Applications 708 Creating Windows Service Projects in VS2008 709 Coding Windows Services 712 Installing a Windows Service 717 Building a Controller to Communicate with a Windows Service 720 Summary 722 32 Remoting 724 Basic Remoting 724 Channels 735 Lifetime Management 738 Summary 741 33 Writing Traditional ASMX Web Services 742 Web Service Basics 742 Using Web Services 748 Summary 752 34 Creating Web and Services with WCF 754 Creating a WCF Application in VS2008 755 Creating a Web Service Contract 756 Implementing Web Service Logic 761 Configuring a Web Service 763 Consuming a Web Service 766 Summary 768 Part 8 Examining .NET Application Architecture and Design 770 35 Using the Visual Studio 2008 Class Designer 772 Visualizing Code 772 Building an Object Model with the Class Designer 778 Summary 783 36 Sampling Design Patterns in C# 784 Overview of Design Patterns 784 The Iterator Pattern 785 Implementing the Proxy Pattern 797 Implementing the Template Pattern 801 Summary 807 37 Building N-Tier/Layer Systems 808 Potential Drag-and-Drop Problems 808 Introducing N-Layer/N-Tier 810 N-Layer Architecture Examples 813 Summary 824 38 Automating Logic with Windows Workflow 826 Starting a Workflow Project 826 Building a Sequential Workflow 827 Building a State Workflow 832 Summary 842 Part 9 Surveying More of the .NET Framework Class Library 844 39 Managing Processes and Threads 846 .NET Process Support 847 Multithreading Overview 852 Thread Synchronization 855 Summary 858 40 Localizing and Globalization 860 Resource Files 860 Multiple Locales 872 Summary 880 41 Performing Interop (P/Invoke and COM) and Writing Unsafe Code 882 Unsafe Code 883 Platform Invoke 893 Communicating with COM from .NET 895 Exposing a .NET Component as a COM Component 898 Introduction to .NET Support for COM+ Services 900 Summary 905 42 Instrumenting Applications with System.Diagnostics Types 908 Simple Debugging 909 Conditional Debugging 910 Runtime Tracing 913 Making Assertions 915 Accessing Built-In Performance Counters 917 Implementing Timers 925 Building a Customized Performance Counter 926 Analyzing Performance with Sampling 937 Summary 946 Part 10 Deploying Code 948 43 Assemblies and Versioning 950 Inside Assemblies 950 Assembly Features 954 Configuration 956 Deployment 959 Summary 959 44 Securing Code 962 Code-Based Security 962 Role-Based Security 971 Security Utilities 973 Summary 974 45 Creating Visual Studio 2008 Setup Projects 976 Running the VS2008 Setup Project Wizard 976 Additional Setup Configuration 979 Summary 983 46 Deploying Desktop Applications 984 Deploying via ClickOnce 984 Configuring ClickOnce 986 Summary 988 47 Publishing Web Applications 990 The Anatomy of a Web Application 990 Web Server Setup 991 Virtual Directory Setup 992 Web Server Deployment 994 Publishing a Web App from VS2008 994 Summary 995 Part 11 Appendixes 996 A: Compiling Programs 998 Advanced 998 Assemblies 1000 B: Getting Help with the .NET Framework 1002 Read This Book 1002 Index 1003 .NET Framework Class Library Documentation 1003 Search Engines 1004 Favorite Websites 1004 Summary 1004
Git-2.21.0-64 for windows Git 2.23 Release Notes ====================== Updates since v2.22 ------------------- Backward compatibility note * The "--base" option of "format-patch" computed the patch-ids for prerequisite patches in an unstable way, which has been updated to compute in a way that is compatible with "git patch-id --stable". * The "git log" command by default behaves as if the --mailmap option was given. UI, Workflows & Features * The "git fast-export/import" pair has been taught to handle commits with log messages in encoding other than UTF-8 better. * In recent versions of Git, per-worktree refs are exposed in refs/worktrees// hierarchy, which means that worktree names must be a valid refname component. The code now sanitizes the names given to worktrees, to make sure these refs are well-formed. * "git merge" learned "--quit" option that cleans up the in-progress merge while leaving the working tree and the index still in a mess. * "git format-patch" learns a configuration to set the default for its --notes= option. * The code to show args with potential typo that cannot be interpreted as a commit-ish has been improved. * "git clone --recurse-submodules" learned to set up the submodules to ignore commit object names recorded in the superproject gitlink and instead use the commits that happen to be at the tip of the remote-tracking branches from the get-go, by passing the new "--remote-submodules" option. * The pattern "git diff/grep" use to extract funcname and words boundary for Matlab has been extend to cover Octave, which is more or less equivalent. * "git help git" was hard to discover (well, at least for some people). * The pattern "git diff/grep" use to extract funcname and words boundary for Rust has been added. * "git status" can be told a non-standard default value for the "--[no-]ahead-behind" option with a new configuration variable status.aheadBehind. * "git fetch" and "git pull" reports when a fetch results in non-fast-forward updates to let the user notice unusual situation. The commands learned "--no-show-forced-updates" option to disable this safety feature. * Two new commands "git switch" and "git restore" are introduced to split "checking out a branch to work on advancing its history" and "checking out paths out of the index and/or a tree-ish to work on advancing the current history" out of the single "git checkout" command. * "git branch --list" learned to always output the detached HEAD as the first item (when the HEAD is detached, of course), regardless of the locale. * The conditional inclusion mechanism learned to base the choice on the branch the HEAD currently is on. * "git rev-list --objects" learned the "--no-object-names" option to squelch the path to the object that is used as a grouping hint for pack-objects. * A new tag.gpgSign configuration variable turns "git tag -a" into "git tag -s". * "git multi-pack-index" learned expire and repack subcommands. * "git blame" learned to "ignore" commits in the history, whose effects (as well as their presence) get ignored. * "git cherry-pick/revert" learned a new "--skip" action. * The tips of refs from the alternate object store can be used as starting point for reachability computation now. * Extra blank lines in "git status" output have been reduced. * The commits in a repository can be described by multiple commit-graph files now, which allows the commit-graph files to be updated incrementally. * "git range-diff" output has been tweaked for easier identification of which part of what file the patch shown is about. Performance, Internal Implementation, Development Support etc. * Update supporting parts of "git rebase" to remove code that should no longer be used. * Developer support to emulate unsatisfied prerequisites in tests to ensure that the remainder of the tests still succeeds when tests with prerequisites are skipped. * "git update-server-info" learned not to rewrite the file with the same contents. * The way of specifying the path to find dynamic libraries at runtime has been simplified. The old default to pass -R/path/to/dir has been replaced with the new default to pass -Wl,-rpath,/path/to/dir, which is the more recent GCC uses. Those who need to build with an old GCC can still use "CC_LD_DYNPATH=-R" * Prepare use of reachability index in topological walker that works on a range (A..B). * A new tutorial targeting specifically aspiring git-core developers has been added. * Auto-detect how to tell HP-UX aCC where to use dynamically linked libraries from at runtime. * "git mergetool" and its tests now spawn fewer subprocesses. * Dev support update to help tracing out tests. * Support to build with MSVC has been updated. * "git fetch" that grabs from a group of remotes learned to run the auto-gc only once at the very end. * A handful of Windows build patches have been upstreamed. * The code to read state files used by the sequencer machinery for "git status" has been made more robust against a corrupt or stale state files. * "git for-each-ref" with multiple patterns have been optimized. * The tree-walk API learned to pass an in-core repository instance throughout more codepaths. * When one step in multi step cherry-pick or revert is reset or committed, the command line prompt script failed to notice the current status, which has been improved. * Many GIT_TEST_* environment variables control various aspects of how our tests are run, but a few followed "non-empty is true, empty or unset is false" while others followed the usual "there are a few ways to spell true, like yes, on, etc., and also ways to spell false, like no, off, etc." convention. * Adjust the dir-iterator API and apply it to the local clone optimization codepath. * We have been trying out a few language features outside c89; the coding guidelines document did not talk about them and instead had a blanket ban against them. * A test helper has been introduced to optimize preparation of test repositories with many simple commits, and a handful of test scripts have been updated to use it. Fixes since v2.22 ----------------- * A relative pathname given to "git init --template= " ought to be relative to the directory "git init" gets invoked in, but it instead was made relative to the repository, which has been corrected. * "git worktree add" used to fail when another worktree connected to the same repository was corrupt, which has been corrected. * The ownership rule for the file descriptor to fast-import remote backend was mixed up, leading to an unrelated file descriptor getting closed, which has been fixed. * A "merge -c" instruction during "git rebase --rebase-merges" should give the user a chance to edit the log message, even when there is otherwise no need to create a new merge and replace the existing one (i.e. fast-forward instead), but did not. Which has been corrected. * Code cleanup and futureproof. * More parameter validation. * "git update-server-info" used to leave stale packfiles in its output, which has been corrected. * The server side support for "git fetch" used to show incorrect value for the HEAD symbolic ref when the namespace feature is in use, which has been corrected. * "git am -i --resolved" segfaulted after trying to see a commit as if it were a tree, which has been corrected. * "git bundle verify" needs to see if prerequisite objects exist in the receiving repository, but the command did not check if we are in a repository upfront, which has been corrected. * "git merge --squash" is designed to update the working tree and the index without creating the commit, and this cannot be countermanded by adding the "--commit" option; the command now refuses to work when both options are given. * The data collected by fsmonitor was not properly written back to the on-disk index file, breaking t7519 tests occasionally, which has been corrected. * Update to Unicode 12.1 width table. * The command line to invoke a "git cat-file" command from inside "git p4" was not properly quoted to protect a caret and running a broken command on Windows, which has been corrected. * "git request-pull" learned to warn when the ref we ask them to pull from in the local repository and in the published repository are different. * When creating a partial clone, the object filtering criteria is recorded for the origin of the clone, but this incorrectly used a hardcoded name "origin" to name that remote; it has been corrected to honor the "--origin " option. * "git fetch" into a lazy clone forgot to fetch base objects that are necessary to complete delta in a thin packfile, which has been corrected. * The filter_data used in the list-objects-filter (which manages a lazily sparse clone repository) did not use the dynamic array API correctly---'nr' is supposed to point at one past the last element of the array in use. This has been corrected. * The description about slashes in gitignore patterns (used to indicate things like "anchored to this level only" and "only matches directories") has been revamped. * The URL decoding code has been updated to avoid going past the end of the string while parsing %-- sequence. * The list of for-each like macros used by clang-format has been updated. * "git branch --list" learned to show branches that are checked out in other worktrees connected to the same repository prefixed with '+', similar to the way the currently checked out branch is shown with '*' in front. (merge 6e9381469e nb/branch-show-other-worktrees-head later to maint). * Code restructuring during 2.20 period broke fetching tags via "import" based transports. * The commit-graph file is now part of the "files that the runtime may keep open file descriptors on, all of which would need to be closed when done with the object store", and the file descriptor to an existing commit-graph file now is closed before "gc" finalizes a new instance to replace it. * "git checkout -p" needs to selectively apply a patch in reverse, which did not work well. * Code clean-up to avoid signed integer wraparounds during binary search. * "git interpret-trailers" always treated '#' as the comment character, regardless of core.commentChar setting, which has been corrected. * "git stash show 23" used to work, but no more after getting rewritten in C; this regression has been corrected. * "git rebase --abort" used to leave refs/rewritten/ when concluding "git rebase -r", which has been corrected. * An incorrect list of options was cached after command line completion failed (e.g. trying to complete a command that requires a repository outside one), which has been corrected. * The code to parse scaled numbers out of configuration files has been made more robust and also easier to follow. * The codepath to compute delta islands used to spew progress output without giving the callers any way to squelch it, which has been fixed. * Protocol capabilities that go over wire should never be translated, but it was incorrectly marked for translation, which has been corrected. The output of protocol capabilities for debugging has been tweaked a bit. * Use "Erase in Line" CSI sequence that is already used in the editor support to clear cruft in the progress output. * "git submodule foreach" did not protect command line options passed to the command to be run in each submodule correctly, when the "--recursive" option was in use. * The configuration variable rebase.rescheduleFailedExec should be effective only while running an interactive rebase and should not affect anything when running a non-interactive one, which was not the case. This has been corrected. * The "git clone" documentation refers to command line options in its description in the short form; they have been replaced with long forms to make them more recognisable. * Generation of pack bitmaps are now disabled when .keep files exist, as these are mutually exclusive features. (merge 7328482253 ew/repack-with-bitmaps-by-default later to maint). * "git rm" to resolve a conflicted path leaked an internal message "needs merge" before actually removing the path, which was confusing. This has been corrected. * "git stash --keep-index" did not work correctly on paths that have been removed, which has been fixed. (merge b932f6a5e8 tg/stash-keep-index-with-removed-paths later to maint). * Window 7 update ;-) * A codepath that reads from GPG for signed object verification read past the end of allocated buffer, which has been fixed. * "git clean" silently skipped a path when it cannot lstat() it; now it gives a warning. * "git push --atomic" that goes over the transport-helper (namely, the smart http transport) failed to prevent refs to be pushed when it can locally tell that one of the ref update will fail without having to consult the other end, which has been corrected. * The internal diff machinery can be made to read out of bounds while looking for --function-context line in a corner case, which has been corrected. (merge b777f3fd61 jk/xdiff-clamp-funcname-context-index later to maint). * Other code cleanup, docfix, build fix, etc. (merge fbec05c210 cc/test-oidmap later to maint). (merge 7a06fb038c jk/no-system-includes-in-dot-c later to maint). (merge 81ed2b405c cb/xdiff-no-system-includes-in-dot-c later to maint). (merge d61e6ce1dd sg/fsck-config-in-doc later to maint).
What’s Inside Preface 1 Java SE5 and SE6 .................. 2 Java SE6 ......................................... 2 The 4th edition........................ 2 Changes .......................................... 3 Note on the cover design ....... 4 Acknowledgements ................ 4 Introduction 9 Prerequisites .......................... 9 Learning Java ....................... 10 Goals ..................................... 10 Teaching from this book ....... 11 JDK HTML documentation ...................... 11 Exercises ............................... 12 Foundations for Java ............ 12 Source code ........................... 12 Coding standards ......................... 14 Errors .................................... 14 Introduction to Objects 15 The progress of abstraction ........................ 15 An object has an interface ........................... 17 An object provides services ................... 18 The hidden implementation .................... 19 Reusing the implementation ................... 20 Inheritance............................ 21 Is-a vs. is-like-a relationships ......24 Interchangeable objects with polymorphism ............. 25 The singly rooted hierarchy .............................. 28 Containers ............................ 28 Parameterized types (Generics) ..29 Object creation & lifetime ... 30 Exception handling: dealing with errors ............... 31 Concurrent programming ... 32 Java and the Internet .......... 33 What is the Web? ......................... 33 Client-side programming ............ 34 Server-side programming ............ 38 Summary .............................. 38 Everything Is an Object 41 You manipulate objects with references ..................... 41 You must create all the objects ....................... 42 Where storage lives ...................... 42 Special case: primitive types ....... 43 Arrays in Java .............................. 44 You never need to destroy an object .................. 45 Scoping ........................................ 45 Scope of objects ........................... 46 Creating new data types: class ..................................... 46 Fields and methods ..................... 47 Methods, arguments, and return values ................. 48 The argument list ......................... 49 Building a Java program ...... 50 Name visibility ............................. 50 Using other components ............. 50 The static keyword ..................... 51 Your first Java program ....... 52 Compiling and running ............... 54 Comments and embedded documentation ..................... 55 Comment documentation ............ 55 Syntax .......................................... 56 Embedded HTML ........................ 56 Some example tags ...................... 57 Documentation example ............. 59 Coding style .......................... 60 Summary .............................. 60 Exercises .............................. 60 Operators 63 Simpler print statements ..... 63 Using Java operators ........... 64 Precedence ........................... 64 Assignment .......................... 65 Aliasing during method calls ....... 66 Mathematical operators....... 67 Unary minus and plus operators ....................... 68 Auto increment and decrement ............................ 69 Relational operators ............ 70 Testing object equivalence ........... 70 Logical operators .................. 71 Short-circuiting ............................ 72 Literals .................................. 73 Exponential notation ................... 74 Bitwise operators .................. 75 Shift operators ......................76 Ternary if-else operator ......79 String operator + and += .............................. 80 Common pitfalls when using operators ........... 81 Casting operators .................. 81 Truncation and rounding ........... 82 Promotion ................................... 83 Java has no “sizeof” ............. 83 A compendium of operators .......................... 84 Summary ............................... 91 Controlling Execution 93 true and false..................... 93 if-else .................................. 93 Iteration ............................... 94 do-while ..................................... 95 for ................................................ 95 The comma operator................... 96 Foreach syntax ......................97 return ................................. 99 break and continue .......... 99 The infamous “goto” ........... 101 switch ................................104 Summary ............................ 106 Initialization & Cleanup 107 Guaranteed initialization with the constructor ........... 107 Method overloading .......... 109 Distinguishing overloaded methods .................. 110 Overloading with primitives ....... 111 Overloading on return values .... 114 Default constructors ........... 114 The this keyword ............... 116 Calling constructors from constructors ...................... 118 The meaning of static ............... 119 Cleanup: finalization and garbage collection ........ 119 What is finalize() for? ............. 120 You must perform cleanup ......... 121 The termination condition ......... 121 How a garbage collector works .. 122 Member initialization ......... 125 Specifying initialization ............. 126 Constructor initialization ... 127 Order of initialization ................ 127 static data initialization ........... 128 Explicit static initialization ...... 130 Non-static instance initialization ................ 132 Array initialization ............. 133 Variable argument lists ............. 137 Enumerated types ............... 141 Summary ............................ 143 Access Control 145 package: the library unit ................... 146 Code organization ...................... 147 Creating unique package names ........................... 148 A custom tool library .................. 151 Using imports to change behavior ..................... 152 Package caveat ........................... 153 Java access specifiers .......... 153 Package access ........................... 153 public: interface access ............ 154 private: you can’t touch that! .. 155 protected: inheritance access . 156 Interface and implementation .......... 158 Class access ........................ 159 Summary ............................ 162 Reusing Classes 165 Composition syntax ........... 165 Inheritance syntax ............. 168 Initializing the base class ........... 169 Delegation ........................... 171 Combining composition and inheritance ................... 173 Guaranteeing proper cleanup .... 174 Name hiding ............................... 177 Choosing composition vs. inheritance .................... 178 protected ......................... 180 Upcasting ............................ 181 Why “upcasting”? ...................... 181 Composition vs. inheritance revisited ..................................... 182 The final keyword ............. 182 final data ................................... 183 final methods ............................ 186 final classes ............................... 187 final caution .............................. 188 Initialization and class loading ................ 189 Initialization with inheritance ... 189 Summary ............................. 191 Polymorphism 193 Upcasting revisited ............. 193 Forgetting the object type .......... 194 The twist ............................. 196 Method-call binding .................. 196 Producing the right behavior ..... 196 Extensibility ............................... 199 Pitfall: “overriding” private methods ...................... 202 Pitfall: fields and static methods .................. 203 Constructors and polymorphism ................... 204 Order of constructor calls ......... 204 Inheritance and cleanup ........... 206 Behavior of polymorphic methods inside constructors .... 210 Covariant return types ........ 211 Designing with inheritance .................. 212 Substitution vs. extension ......... 213 Downcasting and runtime type information ......... 215 Summary ............................. 217 Interfaces 219 Abstract classes and methods ....................... 219 Interfaces ........................... 222 Complete decoupling ......... 225 “Multiple inheritance” in Java ................................ 230 Extending an interface with inheritance .......................... 231 Name collisions when combining Interfaces ................233 Adapting to an interface .... 234 Fields in interfaces ............ 235 Initializing fields in interfaces .. 236 Nesting interfaces .............. 237 Interfaces and factories ..... 239 Summary ............................. 241 Inner Classes 243 Creating inner classes ........ 243 The link to the outer class .................... 244 Using .this and .new ........ 246 Inner classes and upcasting ..................... 247 Inner classes in methods and scopes ........... 249 Anonymous inner classes ........................ 251 Factory Method revisited .......... 254 Nested classes .................... 256 Classes inside interfaces ............ 257 Reaching outward from a multiplynested class ............... 259 Why inner classes? ............. 259 Closures & callbacks .................. 261 Inner classes & control frameworks ................... 263 Inheriting from inner classes ....................... 269 Can inner classes be overridden? ................... 269 Local inner classes .............. 271 Inner-class identifiers ........ 272 Summary ............................ 273 Holding Your Objects 275 Generics and type-safe containers ........... 276 Basic concepts .................... 278 Adding groups of elements ......................... 279 Printing containers ............ 281 List ..................................... 283 Iterator ............................. 286 ListIterator ............................ 288 LinkedList ....................... 289 Stack ................................. 291 Set ...................................... 292 Map ................................... 295 Queue ................................ 298 PriorityQueue ........................ 299 Collection vs. Iterator ... 301 Foreach and iterators ......... 304 The Adapter Method idiom ...... 306 Summary ............................ 308 Error Handling with Exceptions 313 Concepts ............................. 313 Basic exceptions.................. 314 Exception arguments ................. 315 Catching an exception ........ 315 The try block ............................. 316 Exception handlers .................... 316 Creating your own exceptions ................... 317 Exceptions and logging .............. 319 The exception specification ....................... 322 Catching any exception ..... 323 The stack trace .......................... 324 Rethrowing an exception ........... 325 Exception chaining .................... 327 Standard Java exceptions .......................... 330 Special case: RuntimeException ............... 330 Performing cleanup with finally ....................... 332 What’s finally for? .................... 333 Using finally during return .... 335 Pitfall: the lost exception .......... 336 Exception restrictions ....... 338 Constructors ...................... 340 Exception matching ........... 344 Alternative approaches ...... 345 History ...................................... 346 Perspectives ............................... 347 Passing exceptions to the console ............................ 349 Converting checked to unchecked exceptions ........... 350 Exception guidelines ......... 352 Summary ............................ 352 Strings 355 Immutable Strings ............355 Overloading ‘+’ vs. StringBuilder ................. 356 Unintended recursion ....... 359 Operations on Strings ....... 361 Formatting output ............. 362 printf() .................................... 363 System.out.format() ............ 363 The Formatter class ............... 363 Format specifiers ...................... 364 Formatter conversions ........... 366 String.format() ..................... 368 Regular expressions ........... 370 Basics .........................................370 Creating regular expressions ..... 372 Quantifiers ................................. 374 Pattern and Matcher ............. 375 split() ........................................382 Replace operations .................... 383 reset() .......................................384 Regular expressions and Java I/O .............................. 385 Scanning input ................... 386 Scanner delimiters ................. 388 Scanning with regular expressions ................... 389 StringTokenizer ............. 389 Summary ............................ 391 Type Information 393 The need for RTTI .............. 393 The Class object ................ 395 Class literals ............................... 399 Generic class references ............ 401 New cast syntax ........................ 403 Checking before a cast ....... 404 Using class literals .................... 409 A dynamic instanceof .............. 411 Counting recursively .................. 412 Registered factories ........... 413 instanceof vs. Class equivalence......................... 416 Reflection: runtime class information ................ 417 A class method extractor ........... 418 Dynamic proxies ................ 420 Null Objects ........................ 424 Mock Objects & Stubs ................ 429 Interfaces and type information ................ 430 Summary ............................ 436 Generics 439 Comparison with C++ ........ 440 Simple generics .................. 440 A tuple library ............................ 442 A stack class ............................... 444 RandomList ............................ 445 Generic interfaces .............. 446 Generic methods ................ 449 Leveraging type argument inference ...................450 Varargs and generic methods .... 452 A generic method to use with Generators............ 453 A general-purpose Generator . 453 Simplifying tuple use ................. 455 A Set utility................................ 456 Anonymous inner classes ....................... 459 Building complex models ................. 460 The mystery of erasure ...... 462 The C++ approach .................... 464 Migration compatibility ............ 466 The problem with erasure ......... 467 The action at the boundaries .... 468 Compensating for erasure ........................... 471 Creating instances of types ........ 472 Arrays of generics ...................... 475 Bounds ............................... 479 Wildcards ........................... 482 How smart is the compiler? ...... 484 Contravariance .......................... 485 Unbounded wildcards ............... 488 Capture conversion ................... 492 Issues ................................. 493 No primitives as type parameters .................... 493 Implementing parameterized interfaces ........... 495 Casting and warnings ............... 496 Overloading ............................... 498 Base class hijacks an interface .. 498 Self-bounded types ............ 500 Curiously recurring generics .... 500 Self-bounding ............................ 501 Argument covariance ................ 503 Dynamic type safety .......... 506 Exceptions ......................... 507 Mixins ................................ 509 Mixins in C++ ........................... 509 Mixing with interfaces ............... 510 Using the Decorator pattern ....... 511 Mixins with dynamic proxies .... 512 Latent typing ....................... 514 Compensating for the lack of latent typing ...... 518 Reflection ................................... 518 Applying a method to a sequence .............................. 519 When you don’t happen to have the right interface .......... 521 Simulating latent typing with adapters ............................. 523 Using function objects as strategies ....................... 526 Summary: Is casting really so bad? ...................... 531 Further reading .......................... 533 Arrays 535 Why arrays are special ........535 Arrays are first-class objects ............... 536 Returning an array ............. 539 Multidimensional arrays .................................. 540 Arrays and generics ........... 543 Creating test data ............... 546 Arrays.fill() ............................. 546 Data Generators ...................... 547 Creating arrays from Generators ..................... 551 Arrays utilities .................. 555 Copying an array ........................ 555 Comparing arrays ...................... 556 Array element comparisons ...... 557 Sorting an array .........................560 Searching a sorted array ............ 561 Summary ............................ 564 Containers in Depth 567 Full container taxonomy .... 567 Filling containers ............... 568 A Generator solution .............. 569 Map generators ......................... 570 Using Abstract classes ............. 573 Collection functionality ....................... 580 Optional operations ........... 582 Unsupported operations............ 583 List functionality ............... 586 Sets and storage order ...... 589 SortedSet ................................. 591 Queues ................................ 594 Priority queues ........................... 594 Deques ....................................... 595 Understanding Maps ........ 598 Performance .............................. 599 SortedMap ............................. 602 LinkedHashMap ................... 603 Hashing and hash codes .... 605 Understanding hashCodeQ .... 607 Hashing for speed ...................... 610 Overriding hashCode() ........... 613 Choosing an implementation .............. 617 A performance test framework ........................... 618 Choosing between Lists ............ 621 Microbenchmarking dangers .... 626 Choosing between Sets ............. 627 Choosing between Maps ........... 629 Utilities ............................... 632 Sorting and searching Lists ...... 635 Making a Collection or Map unmodifiable ............... 636 Synchronizing a Collection or Map ................... 637 Holding references ............ 639 The WeakHashMap .............. 640 Java 1.0/1.1 containers ...... 642 Vector & Enumeration ........ 642 Hashtable ............................... 643 Stack ........................................ 643 BitSet ....................................... 644 Summary ............................ 646 I/O 647 The File class .................... 647 A directory lister ........................ 647 Directory utilities ...................... 650 Checking for and creating directories ............. 654 Input and output ............... 656 Types of InputStream ............. 657 Types of OutputStream ......... 658 Adding attributes and useful interfaces .......... 659 Reading from an InputStream with FilterlnputStream ........ 660 Writing to an OutputStream with FilterOutputStream ...... 661 Readers & Writers ......... 662 Sources and sinks of data ......... 662 Modifying stream behavior ...... 663 Unchanged classes .................... 664 Off by itself: RandomAccessFile ....... 665 Typical uses of I/O streams .................... 665 Buffered input file ...................... 665 Input from memory .................. 666 Formatted memory input .......... 667 Basic file output ........................ 668 Storing and recovering data ..... 669 Reading and writing random-access files .................. 670 Piped streams ............................ 672 File reading & writing utilities ............... 672 Reading binary files ................... 674 Standard I/O ....................... 675 Reading from standard input .... 675 Changing System.out to a PrintWriter ...................... 676 Redirecting standard I/O .......... 676 Process control ................... 677 New I/O ............................. 679 Converting data.......................... 681 Fetching primitives ................... 684 View buffers ............................... 685 Data manipulation with buffers ............................... 688 Buffer details ............................. 689 Memory-mapped files ............... 692 File locking ................................. 695 Compression ...................... 698 Simple compression with GZIP .................................. 698 Multifile storage with Zip .......... 699 Java ARchives (JARs) ................ 701 Object serialization ............ 703 Finding the class ........................ 706 Controlling serialization ............ 707 Using persistence ....................... 713 XML .................................... 718 Preferences .......................... 721 Summary ............................ 722 Enumerated Types 725 Basic enum features ......... 725 Using static imports with enums ............................... 726 Adding methods to an enum ........................ 727 Overriding enum methods ....... 728 enums in switch statements ............. 728 The mystery of values() ........................ 729 Implements, not inherits ......................... 732 Random selection .............. 732 Using interfaces for organization .................. 734 Using EnumSet instead of flags ................... 737 Using EnumMap ............. 739 Constant-specific methods .............................. 740 Chain of Responsibility with enums ............................... 743 State machines with enums ..... 746 Multiple dispatching ........... 751 Dispatching with enums .......... 753 Using constant-specific methods ......... 755 Dispatching with EnumMaps ...................... 756 Using a 2-D array ....................... 757 Summary ............................ 759 Annotations 761 Basic syntax ....................... 762 Defining annotations ................. 762 Meta-annotations ...................... 763 Writing annotation processors ........ 765 Annotation elements ................. 765 Default value constraints ........... 766 Generating external files............ 766 Annotations don’t support inheritance ................... 769 Implementing the processor...... 769 Using apt to process annotations ............ 772 Using the Visitor pattern with apt .............................. 775 Annotation-based unit testing .......................... 778 Using @Unit with generics ....... 785 No “suites” necessary .................786 Implementing @Unit ............... 787 Removing test code .................... 792 Summary ............................. 795 Concurrency 797 The many faces of concurrency ....................... 798 Faster execution .........................798 Improving code design ............. 800 Basic threading .................. 801 Defining tasks ............................ 801 The Thread class ..................... 802 Using Executors ..................... 804 Producing return values from tasks ................................. 806 Sleeping ..................................... 808 Priority ...................................... 809 Yielding ...................................... 810 Daemon threads ......................... 810 Coding variations ....................... 814 Terminology ............................... 819 Joining a thread ......................... 819 Creating responsive user interfaces ............................ 821 Thread groups ........................... 822 Catching exceptions .................. 822 Sharing resources .............. 824 Improperly accessing resources ................... 825 Resolving shared resource contention ................... 827 Atomicity and volatility ............. 831 Atomic classes ........................... 836 Critical sections .......................... 837 Synchronizing on other objects .............................. 841 Thread local storage ..................843 Terminating tasks .............. 844 The ornamental garden ............ 844 Terminating when blocked ........ 847 Interruption .............................. 848 Checking for an interrupt .......... 854 Cooperation between tasks ..................... 856 wait() and notifyAll() ............ 857 notify() vs. notifyAll() ........... 861 Producers and consumers ........ 863 Producer-consumers and queues ................................ 868 Using pipes for I/O between tasks ............................. 872 Deadlock ............................. 874 New library components ........................ 879 CountDownLatch .................. 879 CyclicBarrier .......................... 881 DelayQueue ........................... 883 PriorityBlockingQueue....... 885 The greenhouse controller with ScheduledExecutor ...... 887 Semaphore ............................. 890 Exchanger .............................. 893 Simulation .......................... 896 Bank teller simulation .............. 896 The restaurant simulation ........ 900 Distributing work ..................... 904 Performance tuning ........... 909 Comparing mutex technologies ................... 909 Lock-free containers .................. 916 Optimistic locking...................... 922 ReadWriteLocks .................... 923 Active objects ..................... 925 Summary ............................ 929 Further reading .......................... 931 Graphical User Interfaces 933 Applets ............................... 935 Swing basics ....................... 935 A display framework .................. 937 Making a button ................. 938 Capturing an event ............. 939 Text areas ........................... 941 Controlling layout .............. 942 BorderLayout ......................... 942 FlowLayout ............................. 943 GridLayout .............................. 944 GridBagLayout....................... 944 Absolute positioning .................. 945 BoxLayout ............................... 945 The best approach? .................... 945 The Swing event model ..... 945 Event and listener types ........... 946 Tracking multiple events ........... 951 A selection of Swing components ............ 953 Buttons ....................................... 953 Icons .......................................... 955 Tool tips ..................................... 957 Text fields ................................... 957 Borders ....................................... 959 A mini-editor.............................. 959 Check boxes .............................. 960 Radio buttons ............................. 961 Combo boxes (drop-down lists) ...................... 962 List boxes .................................. 963 Tabbed panes ............................. 965 Message boxes ........................... 965 Menus ......................................... 967 Pop-up menus ............................ 972 Drawing ...................................... 973 Dialog boxes ............................... 975 File dialogs .................................978 HTML on Swing components .................... 980 Sliders and progress bars ......... 980 Selecting look & feel ................... 981 Trees, tables & clipboard .......... 983 JNLP and Java Web Start ................... 983 Concurrency & Swing ........ 988 Long-running tasks ................... 988 Visual threading ........................ 994 Visual programming and JavaBeans ................... 996 What is a JavaBean? ................. 996 Extracting Beanlnfo with the Introspector ............ 998 A more sophisticated Bean ..... 1002 JavaBeans and synchronization ....................... 1005 Packaging a Bean .................... 1008 More complex Bean support .. 1009 More to Beans .......................... 1010 Alternatives to Swing ........ 1010 Building Flash Web clients with Flex ................ 1011 Hello, Flex ................................. 1011 Compiling MXML .................... 1012 MXML and ActionScript.......... 1013 Containers and controls........... 1013 Effects and styles ..................... 1015 Events ....................................... 1016

16,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧