出于测试目的,让我们假设我画了两个茶壶glutSolidTeapot(),像这样:
glColor3f(1.0f, 0.0f, 0.0f); // Red teapot
glutWireTeapot(1.0f);
glColor3f(0.0f, 1.0f, 0.0f); // Green teapot
glTranslatef(0.0f, 0.0f, 3.0f);
glutWireTeapot(1.0f);
Run Code Online (Sandbox Code Playgroud)
相机最初位于(x,y,z) = (0.0f, 0.0f, 5.0f)并且我正在看z = -1(这是相机位置#1).我相信你明白绿色茶壶是最接近相机的物体,红色茶壶就在后面.问题是红色的那个被画成绿色的那个,看起来不正确:
示例:http://i.stack.imgur.com/8WoEn.png
现在,如果我也移动相机(x,y,z) = (0.0f, 0.0f, -5.0f)并观察z = 1(这是相机位置#2),我会看到绿色前面的红色茶壶,这是正常的行为.红色现在是距离相机最近的物体,绿色物体位于红色物体后面.一切都好.
示例:http://i.stack.imgur.com/eJvPE.png
我知道这与订单有关,如果我切换上面的代码(绿色茶壶代码优先),它将解决相机位置#1中的问题,但问题现在将在相机位置#2中可见.
为什么会发生这种情况?如何保持其他对象后面的对象不被绘制在前面,或者根本不被绘制?
我试图将以下类添加到我的应用程序:
public class AlertDialogHelper {
public static AlertDialog.Builder getDarkDialogBuilder(Context context) {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
int alertDialogTheme = AlertDialog.THEME_HOLO_DARK;
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
alertDialogTheme = AlertDialog.THEME_DEVICE_DEFAULT_DARK;
}
return new AlertDialog.Builder(context, alertDialogTheme);
}
return new AlertDialog.Builder(context);
}
public static AlertDialog getDeleteNoteDialog(Context context, OnClickListener deleteListener) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setMessage(R.string.dialog_delete_message);
builder.setPositiveButton(R.string.button_delete, deleteListener);
builder.setNegativeButton(R.string.button_cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
return builder.create();
}
}
Run Code Online (Sandbox Code Playgroud)
无论何时何地AlertDialogHelper.getDeleteNoteDialog(this, null)在Android 1.6上运行时我都会调用,我收到以下错误:
03-28 18:56:07.828: E/dalvikvm(303): Could …Run Code Online (Sandbox Code Playgroud) 请看以下示例:
export interface IBaseIconProperties {
path: string;
}
export default class BaseIcon extends React.Component<IBaseIconProperties, any> {
public render() {
return (
<SvgIcon style={{width: 32, height: 32}}>
<path d={this.props.path} />
</SvgIcon>
);
}
}
export default class Foo extends React.Component<any, any> {
public render() {
return <BaseIcon path="/* SVG path for Foo button goes here... */"/>;
}
}
export default class Bar extends React.Component<any, any> {
public render() {
return <BaseIcon path="/* SVG path for Bar button goes here... */"/>;
} …Run Code Online (Sandbox Code Playgroud) 我按照Apollo Docs 教程使用 TypeScript 构建 Apollo Server (Express),并且还使用GraphQL 代码生成器根据我的 GraphQL 架构生成必要的类型。
这是我当前的codegen.json配置:
{
"schema": "./lib/schema/index.graphql",
"generates": {
"./dist/typings/graphql/schema.d.ts": {
"plugins": [
"typescript",
"typescript-resolvers"
],
"config": {
"typesPrefix": "GQL",
"skipTypename": true,
"noSchemaStitching": true,
"useIndexSignature": true
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是我当前基于教程的 GraphQL 模式(它并不完整,我还没有完成整个事情,我已经修剪了一些东西以使示例更小):
type Query {
launch(id: ID!): Launch
}
type Launch {
id: ID!
site: String
mission: Mission
}
enum PatchSize {
SMALL
LARGE
}
type Mission {
name: String
missionPatch(mission: String, size: PatchSize): String …Run Code Online (Sandbox Code Playgroud) 我正在尝试从头开始在C中构建自己的Hash Table作为练习,我一次只做一小步.但我有一点问题......
我将哈希表结构声明为指针,因此我可以使用我想要的大小初始化它,并在加载因子很高时增加它的大小.
问题是我正在创建一个只有2个元素的表(它仅用于测试目的),我只为这2个元素分配内存,但我仍然能够写入我不应该写入的内存位置.而且我也可以读取我没有写过的内存位置.
这是我目前的代码:
#include <stdio.h>
#include <stdlib.h>
#define HASHSIZE 2
typedef char *HashKey;
typedef int HashValue;
typedef struct sHashTable {
HashKey key;
HashValue value;
} HashEntry;
typedef HashEntry *HashTable;
void hashInsert(HashTable table, HashKey key, HashValue value) {
}
void hashInitialize(HashTable *table, int tabSize) {
*table = malloc(sizeof(HashEntry) * tabSize);
if(!*table) {
perror("malloc");
exit(1);
}
(*table)[0].key = "ABC";
(*table)[0].value = 45;
(*table)[1].key = "XYZ";
(*table)[1].value = 82;
(*table)[2].key = "JKL";
(*table)[2].value = 13;
}
int main(void) {
HashTable t1 …Run Code Online (Sandbox Code Playgroud) 假设我有以下内容:
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Run Code Online (Sandbox Code Playgroud)
如何使用C 搜索dummy或dummy text在该字符串中?有没有简单的方法来做或只有强大的字符串操作?我只需要搜索它并返回一个带有结果的布尔值.
编辑:
你们围绕这个主题创建了一个大讨论,并提出了一些算法,我不介意,因为这可能对其他人,甚至将来我都有用.但无论时间/空间的复杂性如何,我真正想要的是最简单的方法.这对我正在做的事情并不重要.因此,strstr轻松快速地解决了我的问题.我真的得给我一些标准的C函数chet表.
我正在使用fwrite()并且fread()第一次将一些数据结构写入磁盘,我对最佳实践和正确的处理方式有几个问题.
我正在写入磁盘(所以我以后可以读回来)是在Graph结构中插入的所有用户配置文件.每个图形顶点都是以下类型:
typedef struct sUserProfile {
char name[NAME_SZ];
char address[ADDRESS_SZ];
int socialNumber;
char password[PASSWORD_SZ];
HashTable *mailbox;
short msgCount;
} UserProfile;
Run Code Online (Sandbox Code Playgroud)
这就是我目前正在将所有配置文件写入磁盘的方式:
void ioWriteNetworkState(SocialNetwork *social) {
Vertex *currPtr = social->usersNetwork->vertices;
UserProfile *user;
FILE *fp = fopen("save/profiles.dat", "w");
if(!fp) {
perror("fopen");
exit(EXIT_FAILURE);
}
fwrite(&(social->usersCount), sizeof(int), 1, fp);
while(currPtr) {
user = (UserProfile*)currPtr->value;
fwrite(&(user->socialNumber), sizeof(int), 1, fp);
fwrite(user->name, sizeof(char)*strlen(user->name), 1, fp);
fwrite(user->address, sizeof(char)*strlen(user->address), 1, fp);
fwrite(user->password, sizeof(char)*strlen(user->password), 1, fp);
fwrite(&(user->msgCount), sizeof(short), 1, fp);
break;
currPtr = currPtr->next;
}
fclose(fp); …Run Code Online (Sandbox Code Playgroud) 我有一个简单的INSERT查询,当主键是重复时我需要使用UPDATE.在MySQL中这似乎更容易,在Oracle中我似乎需要使用MERGE.
我能找到的MERGE的所有例子都有某种"源"和"目标"表,在我的例子中,源和目标是同一个表.我无法理解创建自己的查询的示例.
MERGE是唯一的方式,还是有更好的解决方案?
INSERT INTO movie_ratings
VALUES (1, 3, 5)
Run Code Online (Sandbox Code Playgroud)
它基本上是这个,主键是前2个值,所以更新将是这样的:
UPDATE movie_ratings
SET rating = 8
WHERE mid = 1 AND aid = 3
Run Code Online (Sandbox Code Playgroud)
我想过使用一个触发器,它会在调用INSERT时自动执行UPDATE语句,但前提是主键是重复的.这样做有什么问题吗?我需要一些关于触发器的帮助,因为我在尝试理解它们并做我自己时遇到了一些困难.
我在Docker Hub上有以下自动化构建:
作为参考,这两个都是Dockerfile:
这是构建的构建日志arm32v7:
Building in Docker Cloud's infrastructure...
Cloning into '.'...
Warning: Permanently added the RSA host key for IP address '192.30.253.113' to the list of known hosts.
Reset branch 'master'
Your branch is up-to-date with 'origin/master'.
Executing build hook...
Sending build context to Docker daemon 88.06kB
Step 1/17 : ARG ALPINE_VERSION="3.8"
Step 2/17 : ARG S6_OVERLAY_VERSION="1.21.7.0"
Step 3/17 : FROM golang:1.11-alpine${ALPINE_VERSION} AS builder
1.11-alpine3.8: Pulling from library/golang
169185f82c45: Pulling fs layer
34c29055ee42: Pulling fs …Run Code Online (Sandbox Code Playgroud) 我有这个应用程序,用户可以更改文本文件,当他们忘记保存文本文件时,会弹出一条消息提醒他们没有保存更改,并询问他们是否要保存更改或不使用两个按钮"是"和不".它还有一个小复选框,上面写着"禁用此警告".同样地说,如果用户检查它,当文本文件有未保存的更改时,消息将永远不会再次弹出.
几个问题:
1)如果用户仅选择"是",是否应记住复选框值(如果已选中),则仅选择"否"或其中任何一个?
2)假设用户选中了复选框,因此不会再次警告未保存的更改.下次用户忘记保存更改时,预期的行为应该是什么?
在用户禁用警告后,我是否应始终采取默认操作(是:保存更改,不:放弃更改)?如果是这样,哪个动作?
或者我是否应该始终保存更改,或者在他禁用警告后立即将更改相应地丢弃到最后一个用户操作?