c语言接口与实现作用,C语言接口与实现

0780911f216d84e511ed0af43aec55b3.png

出版信息

(美)David R. Hanson / 人民邮电出版社 / 2010-8 / 79.00元

内容简介

可重用的软件模块是构建大规模可靠应用程序的基石,创建可重用的软件模块是每个程序员和项目经理必须掌握的技能。C语言对创建可重用的API提供的语言和功能支持非常少,虽然C程序员写应用时都会用到API和库,但却很少有人去创建和发布新的能广泛应用的API。本书介绍用一种基于接口的设计方法创建可重用的API,这一方法将接口与实现分离开来,且与语言无关。书中详细描述了24个接口及其实现,便于读者深入了解此方法。这些接口涉及很多计算机领域的知识,包括数据结构、算法、字符串处理和并发程序。

本书是C语言领域的的经典名著,出版十余年仍畅销不衰,是几代程序员倍加推崇的力作。

作者简介

David R.Hanson 普林斯顿大学计算机科学系教授,有着二十多年编程语言研究经验。他曾经同贝尔实验室合作开展研究工作,是适用于UNIX系统上的高质量C编译器Icc的开发者之一。另著有A Retargetable C Compiler: Design and Implementation一书。

目录

1 Introduction 1

1.1 Literate Programs 2

1.2 Programming Style 8

1.3 Efficiency 11

Further Reading 12

Exercises 13

2 Interfaces and Implementations 15

2.1 Interfaces 15

2.2 Implementations 18

2.3 Abstract Data Types 21

2.4 Client Responsibilities 24

2.5 Efficiency 30

Further Reading 30

Exercises 31

3 Atoms 33

3.1 Interface 33

3.2 Implementation 34

Further Reading 42

4 Exceptions and Assertions 45

4.1 Interface 47

.4.2 Implementation 53

4.3 Assertions 59

Further Reading 63

Exercises 64

5 Memory Management 67

5.1 Interface 69

5.2 Production Implementation 73

5.3 Checking Implementation 76

Further Reading 85

Exercises 86

6 More Memory Management 89

6.1 Interface 90

6.2 Implementation 92

Further Reading 98

Exercises 100

7 Lists 103

7.1 Interface 103

7.2 Implementation 108

Further Reading 113

Exercises 114

8 Tables 115

8.1 Interface 115

8.2 Example: Word Frequencies 118

8.3 Implementation 12 5

Further Reading 132

Exercises 133

9 Sets 137

9.1 Interface 138

9.2 Example: Cross-Reference Listings 140

9.3 Implementation 148

9.3.1 Member Operations 150

9.3.2 Set Operations 154

Further Reading 158

Exercises 158

10 Dynamic Arrays

10.1 Interfaces 162

10.2 Implementation 165

Further Reading 169

Exercises 169

11 Sequences 171

11.1 Interface 171

11.2 Implementation 174

Further Reading 180

Exercises 180

12 Rings 183

12.1 Interface 183

12.2 Implementation 187

Further Reading 196

Exercises 197

13 Bit Vectors 199

13.1 Interface 199

13.2 Implementation 202

13.2.1 Member Operations 204

13.2.2 Comparisons 209

13.2.3 Set Operations 211

Further Reading 213

Exercises 21314 Formatting 215

14.1 Interface 216

14.1.1 Formatting Functions 216

14.1.2 Conversion Functions 219

14.2 Implementation 224

14.2.1 Formatting Functions 225

14.2.2 Conversion Functions 232

Further Reading 238

Exercises 239

15 Low-LevelStrings 241

15.1 Interface 243

15.2 Example: Printing Identifiers 249

15.3 Implementation 251

15.3.1 String Operations 252

15.3.2 Analyzing Strings 258

15.3.3 Conversion Functions 263

Further Reading 264

Exercises 265

16 High-LevelStrings 269

16.1 Interface 269

16.2 Implementation 276

16.2.1 String Operations 281

16.2.2 Memory Management 285

16.2.3 Analyzing Strings 288

16.2.4 Conversion Functions 293

Further Reading 293

Exercises 294

17 Extended-Precision Arithmetic 297

17.1 Interface 297

17.2 Implementation 303

17.2.1 Addition and Subtraction 305

17.2.2 Multiplication 307

17.2.3 Division and Comparison 309

17.2.4 Shifting 315

17.2.5 String Conversions 319

Further Reading 321

Exercises 322

18 Arbitrary-Precision Arithmetic 323

18.1 Interface 323

18.2 Example: A Calculator 327

18.3 Implementation 334

18.3.1 Negation and Multiplication 337

18.3.2 Addition and Subtraction 338

18.3.3 Division 342

18.3.4 Exponentiation 343

18.3.5 Comparisons 346

18.3.6 Convenience Functions 347

18.3.7 Shifting 349

18.3.8 String and Integer Conversions 350

Further Reading 353

Exercises 354

19 Multiple-Precision Arithmetic 357

19.1 Interface 358

19.2 Example: Another Calculator 365

19.3 Implementation 373

19.3.1 Conversions 377

19.3.2 Unsigned Arithmetic 380

19.3.3 Signed Arithmetic 383

19.3.4 Convenience Functions 388

19.3.5 Comparisons and Logical Operations 395

19.3.6 String Conversions 399

Further Reading 402

Exercises 402

20 Threads 405

20.1 Interfaces 408

20.1.1 Threads 409

20.1.2 General Semaphores 413

20.1.3 Synchronous Communication Channels 417

20.2 Examples 418

20.2.1 Sorting Concurrently 418

20.2.2 Critical Regions 423

20.2.3 Generating Primes 426

20.3 Implementations 431

20.3.1 Synchronous Communication Channels 431

20.3.2 Threads 434

20.3.3 Thread Creation and Context-Switching 446

20.3.4 Preemption 454

20.3.5 General Semaphores 457

20.3.6 Context-Switching on the MIPS and ALPHA 459

Further Reading 463

Exercises 465

Interface Summary 469

Bibliography 497

Index 505

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
对于c语言接口网上的资料是少之又少,所以下面这些文字全是我一个字一个字打印上来的希望大家 能对的起我的付出: 现在的程序员都面临大量的关于应用程序接口(Application Programming Interface,API) 的信息,大多数人都会使用API和程序库,并在其所写的每一个应用程序中实现它们,但是很少人 会创建或发布新的能广泛应用的API,事实上,程序员似乎倾向与循环使用他们自己的东西,而不 愿意查找,能满足他们要求的程序库,这或许是因为写特定应用程序代码要比查找设计好的API容易。 这里我所提到的是一种基于接口与其实现的设计方法,并且通过对24个接口及其实现的描述详细地演示了这种方法,这些接口涉及到计算机领域的很多知识,其中包括数据结构,算法,字符串处理 和并发程序,这些实现并不是简单的玩具----它们是为了在你们所设计的软件代码中使用而设计的。(当然了我会通过阅读量来看是否继续发下去,人要少了我就没有必要浪费时间了) c编程语言对基于接口设计方法的支持是极少的。 而面向对象的语言,如c++,Modula-3,则鼓励将接口实现分离,基于接口的设计独立与任何特定 的语言,但是它要求程序员对像c一样的语言有更多的驾驭能力和更高的警惕性,因为这类语言很容易破坏带有隐含实现信息的接口,反之亦然。 然而一但掌握了基于接口的设计方法,就能够在服务于众多应用程序的通用接口基础上建立应用程序,从而加速开发,在一些c++环境中的基础类库就体现了这种效果。 增加对现有软件的重用---接口实现库,能够减少初始开发成本,同时还能减少维护成本,因为应用程序的更多部分都建立在经过良好测试的通用接口实现上,这里我提到的接口是针对数据结构的,但它并不是数据结构,我重点将放在算法引擎----包装数据结构以供应用程序使用----而不在数据结构算法本身,接口的示例和实现都以literate程序的方式给出,换句话说就是源代码及其解释是按照最适合理解代码的顺序交织出现的。 下面我将我想要给大家讲的内容分一下类: 基础 1,接口实现 2,异常与断言 3,内寸管理 4,进一步内寸管理 数据结构 5,链表 6,表格 7,集合 8,动态数组 9,序列 10,环 11,位向量 字符串 12,原子 13,格式化 14,低级字符串 15,高级字符串 算法 16,扩展精度算法 17,任意精度算法 18,多精度算法 线程 19,线程 建议: 看到这里的朋友我相信对c语言都有了很长时间的学习 如果你还没有搞懂c语言的全部内容,我强烈建议你先别看这里
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值