Programming abstractions in C阅读笔记p111-p113: boilerplate
《Programming Abstractions In C》学习第47天,p111-p113,总结如下:
一、技术总结
1.boilerplate
/*
* File: random.h
* Version: 1.0
* Last modified on Fri Jul 22 16:44:36 1994 by eroberts
* -----------------------------------------------------
* This interface provides several functions for generating
* pseudo-random numbers.
*/
#ifndef _random_h
#define _random_h
#include "genlib.h"
#include <stdlib.h>
/*
* Constant: RAND_MAX
* ------------------
* Unfortunately, several libraries that supposedly conform to
* the ANSI standard do not define RAND_MAX in <stdlib.h>. To
* reduce portability problems, this interface defines RAND_MAX
* to be the largest positive integer if it is undefined.
*/
#ifndef RAND_MAX
# define RAND_MAX ((int) ((unsigned) ~0 >> 1))
#endif
/*
* Function: Randomize
* Usage: Randomize();
* -------------------
* This function sets the random seed so that the random sequence
* is unpredictable. During the debugging phase, it is best not
* to call this function, so that program behavior is repeatable.
*/
void Randomize(void);
/*
* Function: RandomInteger
* Usage: n = RandomInteger(low, high);
* ------------------------------------
* This function returns a random integer in the range low to high,
* inclusive.
*/
int RandomInteger(int low, int high);
/*
* Function: RandomReal
* Usage: d = RandomReal(low, high);
* ---------------------------------
* This function returns a random real number in the half-open
* interval [low .. high), meaning that the result is always
* greater than or equal to low but strictly less than high.
*/
double RandomReal(double low, double high);
/*
* Function: RandomChance
* Usage: if (RandomChance(p)) . . .
* ---------------------------------
* The RandomChance function returns TRUE with the probability
* indicated by p, which should be a floating-point number between
* 0 (meaning never) and 1 (meaning always). For example, calling
* RandomChance(.30) returns TRUE 30 percent of the time.
*/
bool RandomChance(double p);
#endif
p113,These three lines are often referred to as interface boilerplate。boilerplate这个词会在计算机相关的教材中会经常看到,英文的意思是:“text that can be copied and used in computer program,with only small changes.”(模板),之所以叫模板,是因为在每个头文件中都有这三句。这个单词不难理解,关键是通过此次的教材对这个单词有一个具体的、形象的记录,当提到这个单词,就知道具体指的是什么。
二、英语总结
1.roll a die一句里面的die是什么意思?
答:die: n.a small cube with a different number of spots on each side.(骰子),所以roll a die的就是"掷骰子"。
2.along with语法
答:along with在表示伴随、以及或连同等意思时,两者之间无先后顺序,可能在前也可能在后。这点与follow不同。示例:For each of these functions, the interface contains one-line prototype along with a comment that describe the purpose of the function from the perspective of clients.
3.up to 语法
答:原文:The line:
#ifndef _random_h
cause the compiler to skip any text up to the #endif line if the the symbol _random_h has been previously defined。
up to短语主要有两种用法:
(1)adv. used to say that sth is less than or equal to but not more than a stated value。
(2)adv. until。
都表示的是“程度”,而不是“方向”。
三、参考资料
1.编程
1)Eric S.Roberts,《Programming Abstractions in C》:https://book.douban.com/subject/2003414
2.英语
1)Etymology Dictionary:https://www.etymonline.com
2)Cambridage Dictionary:https://dictionary.cambridge.org
欢迎搜索及关注:编程人(a_codists)
Programming abstractions in C阅读笔记p111-p113: boilerplate的更多相关文章
- Mongodb Manual阅读笔记:CH3 数据模型(Data Models)
3数据模型(Data Models) Mongodb Manual阅读笔记:CH2 Mongodb CRUD 操作Mongodb Manual阅读笔记:CH3 数据模型(Data Models)Mon ...
- Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第二十三章:角色动画
原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第二十三章:角色动画 学习目标 熟悉蒙皮动画的术语: 学习网格层级变换 ...
- Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第十一章:模板测试
原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第十一章:模板测试 代码工程地址: https://github.co ...
- Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第六章:在Direct3D中绘制
原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第六章:在Direct3D中绘制 代码工程地址: https://gi ...
- Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第四章:Direct 3D初始化
原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第四章:Direct 3D初始化 学习目标 对Direct 3D编程在 ...
- Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第二章:矩阵代数
原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第二章:矩阵代数 学习目标: 理解矩阵和与它相关的运算: 理解矩阵的乘 ...
- Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第一章:向量代数
原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第一章:向量代数 学习目标: 学习如何使用几何学和数字描述 Vecto ...
- 阅读笔记 1 火球 UML大战需求分析
伴随着七天国庆的结束,紧张的学习生活也开始了,首先声明,阅读笔记随着我不断地阅读进度会慢慢更新,而不是一次性的写完,所以会重复的编辑.对于我选的这本 <火球 UML大战需求分析>,首先 ...
- [阅读笔记]Software optimization resources
http://www.agner.org/optimize/#manuals 阅读笔记Optimizing software in C++ 7. The efficiency of differe ...
- 《uml大战需求分析》阅读笔记05
<uml大战需求分析>阅读笔记05 这次我主要阅读了这本书的第九十章,通过看这章的知识了解了不少的知识开发某系统的重要前提是:这个系统有谁在用?这些人通过这个系统能做什么事? 一般搞清楚这 ...
随机推荐
- 2022-09-02:以下go语言代码输出什么?A:9;B:11;C:编译错误;D:不确定。
2022-09-02:以下go语言代码输出什么?A:9:B:11:C:编译错误:D:不确定. package main import ( "fmt" ) func main() { ...
- 2022-02-15:扫地机器人。 房间(用格栅表示)中有一个扫地机器人。 格栅中的每一个格子有空和障碍物两种可能。 扫地机器人提供4个API,可以向前进,向左转或者向右转。每次转弯90度。 当扫地机
2022-02-15:扫地机器人. 房间(用格栅表示)中有一个扫地机器人. 格栅中的每一个格子有空和障碍物两种可能. 扫地机器人提供4个API,可以向前进,向左转或者向右转.每次转弯90度. 当扫地机 ...
- 2021-08-04:给定一个字符串str,当然可以生成很多子序列。返回有多少个子序列是回文子序列,空序列不算回文。比如,str = “aba”,回文子序列:{a}、{a}、 {a,a}、 {b}、{
2021-08-04:给定一个字符串str,当然可以生成很多子序列.返回有多少个子序列是回文子序列,空序列不算回文.比如,str = "aba",回文子序列:{a}.{a}. {a ...
- 2021-10-25:计数质数。统计所有小于非负整数 n 的质数的数量。力扣204。
2021-10-25:计数质数.统计所有小于非负整数 n 的质数的数量.力扣204. 福大大 答案2021-10-25: 自然智慧即可.从i从3开始遍历,每次加2,i*i<n. 代码用golan ...
- Vue跨域详解
碰到这种问题,其实你的接口已经通了,但是在页面上就是访问不通过. 你可以把API请求地址单独拎出来新开个网站打开看请求是否成功,成功,但是你的项目不通. 有那么几个可能吧: 1.请求头设置错误 hea ...
- PTA L1-064 估值一亿的AI核心代码
PTA L1-064 估值一亿的AI核心代码 有坑!不少 题目链接 题目及分析 题目: 本题要求你实现一个稍微更值钱一点的 AI 英文问答程序,规则是: 1. 无论用户说什么,首先把对方说 ...
- XTU OJ 程设训练 1407 Alice and Bob
题目描述 Alice和Bob打球,已知他们打过的每一回合的输赢情况,每个回合获胜的一方可以得一分. Alice可以随意设定赢得一局比赛所需的分数和赢得整个比赛所需要的局数. Alice想赢得比赛,请问 ...
- vue cli3 整合Cesium,处理build 时内存溢出问题
一直使用cesium,但是都是使用script直接引入的,但是在将其放置在增加路由的子页面中中时会出现一个问题,刷新后提示cesium is undefined 看直接引入cesium.js < ...
- 使用git 将本地代码上传码市私用仓库操作
1 现在在登录码市建立项目 2 本地建立一个文件夹,然后使用git bash 3 初始化本地库 git init 4,进入刚刚在码云新建的项目里,复制框框里的路径 5,然后在回到本地新建的 ...
- odoo开发教程八:qweb引擎
一:简介 QWeb是一个基于xml的模板引擎,用于生成HTML片段和页面,模板指令是写在xml标签中的以t-开头的属性,比如t-if如果要让一个标签不被渲染,可以采用t来包裹,这样会执行它里面的命令但 ...