15,440
社区成员
发帖
与我相关
我的任务
分享
class GLStroke
{
public:
enum {
SECTION_SEG = 1, // 颜色数组模式下至少两个带才能抗锯齿
PATH_SEG = 1, // 路径方向的段数
VER_SIZE = 2, // x y
COLOR_SIZE = 4, // r g b a
TEXCOORD_SIZE = 2, // u v
TRI_SIZE = 3, // three vertices
IDX_SIZE = 6
};
typedef sVertex Vertex; // 存储采用int
typedef Vec2f RVec; // 计算采用浮点数
typedef unsigned short IType;
typedef void(*PatchProcFuncType)(float*, float*);
GLStroke(Vertex* vBuffer, IType* iBuffer, IType beg);
~GLStroke();
// pV指向顶点坐标
void setupStroke(int* pV, int count, int wid, unsigned int c);
int getVertexNum() const { return verNum; }
int getIndexNum() const { return indiceNum; }
int getIndexBeg() const { return indiceBeg; }
void dumpToFile();
private:
// 开始和结尾处两个截面
void _processSpecialSection(int leftX, int unitX, const RVec& p1, const RVec& p2, int verPos, bool isBegCap=true);
// 取消射线求交方式,直接局部计算
void _setupVertices(int* pV, int count);
// 顶点变换到左手坐标系下 绘制三角形
void _setupIndicesPathFirst();
IType* pTriIndices;
Vertex* pVertex;
IType indiceBeg;
unsigned short indiceNum; // stroke的顶点索引个数
unsigned short verNum; // stroke顶点个数
unsigned short pathSize; // 放样路径的顶点个数
unsigned short width; // stroke的宽度
unsigned int color; // stroke的主色
};
package com.et.bothwayLikedList;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
★☆ @author: The One ☆★
★☆ @time:2014年4月8日 下午7:40:18 ☆★
★☆ @version:1.0 ☆★
★☆ @lastMotifyTime: ☆★
★☆ @ClassAnnotation: ☆★
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
*/
public class MyLinked<T> extends AbstractList<T> implements List<T> {
private class Node {
private Node last;
private Node next;
private T value;
public Node(T value) {
this.value = value;
}
}
private int size;
private Node tail;
private Node root;
@Override
public void add(int index, T element) {
Node newNode = new Node(element);
if (index == 0) {
newNode.next = root;
root.last = newNode;
root = newNode;
size++;
return;
}
if (index == size) {
add(element);
return;
}
Node firstNode = getNode(index).last;
Node lastNode = firstNode.next;
firstNode.next = newNode;
newNode.last = firstNode;
newNode.next = lastNode;
lastNode.last = newNode;
size++;
}
@Override
public boolean add(T element) {
Node newNode = new Node(element);
if (root == null) {
root = newNode;
tail = newNode;
size++;
return true;
}
tail.next = newNode;
newNode.last = tail;
tail = newNode;
size++;
return true;
}
@Override
public boolean addAll(Collection<? extends T> conllection) {
for (T element : conllection) {
add(element);
}
return true;
}
@Override
public boolean addAll(int index, Collection<? extends T> collection) {
checkIndex(index);
for (T c : collection) {
add(index++, c);
}
return true;
}
private void checkIndex(int index) {
if ((index > (size - 1)) || (index < 0) || ((size == 0) && (index == 0))) {
throw new IndexOutOfBoundsException();
}
}
@Override
public void clear() {
size = 0;
root = null;
tail = null;
}
@Override
public boolean contains(Object value) {
Node nextNode = root;
while (nextNode != null) {
if (value.equals(nextNode.value)) {
return true;
}
nextNode = nextNode.next;
}
return false;
}
@Override
public boolean containsAll(Collection<?> collection) {
for (Object object : collection) {
if (!contains(object)) {
return false;
}
}
return true;
}
@Override
public T get(int index) {
checkIndex(index);
T value = getNode(index).value;
return value;
}
private Node getForward(int index) {
Node tempNext = root;
int i = 0;
do {
if (i == index) {
return tempNext;
}
i++;
tempNext = tempNext.next;
} while (tempNext != null);
return null;
}
public Node getNode(int index) {
checkIndex(index);
if (index >= (size / 2)) {
return getReverse(index);
} else {
return getForward(index);
}
}
private Node getReverse(int index) {
Node tempLast = tail;
int i = size - 1;
do {
if (i == index) {
return tempLast;
}
i--;
tempLast = tempLast.last;
} while (tempLast != null);
return null;
}
@Override
public int indexOf(Object value) {
Node nextNode = root;
int i = 0;
do {
if (value.equals(nextNode.value)) {
return i;
}
i++;
nextNode = nextNode.next;
} while (nextNode != null);
return -1;
}
@Override
public boolean isEmpty() {
return size == 0;
}
@Override
public int lastIndexOf(Object value) {
Node lastNode = tail;
int lastIndex = size - 1;
do {
if (value.equals(lastNode.value)) {
return lastIndex;
}
lastIndex--;
lastNode = lastNode.last;
} while (lastNode != null);
return -1;
}
@Override
public T remove(int index) {
checkIndex(index);
Node remove = getNode(index);// 当前删除的Node
Node father = remove.last;// 删除元素的上一个Node
Node last = remove.next;// 删除元素的下一个Node
if (root.equals(remove)) {// 删除的是头1:里面有两个以上元素,则头为下一个Node,并把上一个last赋为null。
// 2:如果只存在一个元素,又要删除该元素,也是把头为下一个Node(此时下一个Node必然为null),因为删除的是该容器的最后一个元素,所以也把tail赋为null
root = last;
if (root != null) {
root.last = null;
}
if ((size == 1) && (index == 0)) {
tail = null;
}
size--;
return remove.value;
}
if (tail.equals(remove)) {
tail = father;
tail.next = null;
size--;
return remove.value;
}
father.next = last;
last.last = father;
size--;
return remove.value;
}
@Override
public boolean remove(Object value) {
Node nextNode = root;
while (nextNode != null) {
if (value.equals(nextNode.value)) {
Node father = nextNode.last;
Node last = nextNode.next;
if (root.equals(nextNode)) {
root = last;
if (root != null) {
root.last = null;
}
if ((size == 1) && value.equals(root.value)) {
tail = null;
}
size--;
return true;
}
if (tail.equals(nextNode)) {
tail = father;
tail.next = null;
size--;
return true;
}
father.next = last;
last.last = father;
size--;
return true;
}
nextNode = nextNode.next;
}
return false;
}
@Override
public boolean removeAll(Collection<?> collection) {
for (Object object : collection) {
remove(object);
}
return true;
}
@Override
public T set(int index, T element) {
Node setNode = getNode(index);
T setValue = setNode.value;
setNode.value = element;
return setValue;
}
@Override
public int size() {
return size;
}
@Override
public List<T> subList(int fromIndex, int toIndex) {
if ((fromIndex < 0) || (fromIndex >= size) || (toIndex <= 0) || (toIndex > size)) {
throw new IndexOutOfBoundsException();
}
Node fromNode = getNode(fromIndex);
List<T> list = new ArrayList<>();
while (fromNode != null) {
if (fromIndex == toIndex) {
break;
}
list.add(fromNode.value);
fromNode = fromNode.next;
fromIndex++;
}
return list;
}
@Override
public Object[] toArray() {
Object[] objects = subList(0, size).toArray();
return objects;
}
}
// WebServerInfo.h: interface for the CWebServerInfo class.
//
//////////////////////////////////////////////////////////////////////
#ifndef __WebServerInfo_H__
#define __WebServerInfo_H__
#pragma once
class CWebServerInfo
{
public:
CWebServerInfo(void);
~CWebServerInfo(void);
int GetIISVersion(CString& strIISVersion);
int GetApacheVersion(CString& strApacheVersion);
int GetIISLogEventFiles(CString& strIISLogEevntFile);
char** EnumFiles(const char *directory, int *count);
private:
int GetIISLogFileDirectory();
int GetApacheServerRoot(HKEY hKey, CString strSubKey, CString& strServerRoot);
int GetApacheLogFileDirectory(CString strServerRoot);
static bool IsIISInstalled();
private:
DWORD m_dwIISMajorVersion;
};
#endif //__WebServerInfo_H__
#define __define_initcall(level,fn,id) \
static initcall_t __initcall_##fn##id __used \
__attribute__((__section__(".initcall" level ".init"))) = fn
#define early_initcall(fn) __define_initcall("early",fn,early)
#define pure_initcall(fn) __define_initcall("0",fn,0)
#define core_initcall(fn) __define_initcall("1",fn,1)
#define core_initcall_sync(fn) __define_initcall("1s",fn,1s)
#define postcore_initcall(fn) __define_initcall("2",fn,2)
#define postcore_initcall_sync(fn) __define_initcall("2s",fn,2s)
#define arch_initcall(fn) __define_initcall("3",fn,3)
#define arch_initcall_sync(fn) __define_initcall("3s",fn,3s)
#define subsys_initcall(fn) __define_initcall("4",fn,4)
#define subsys_initcall_sync(fn) __define_initcall("4s",fn,4s)
#define fs_initcall(fn) __define_initcall("5",fn,5)
#define fs_initcall_sync(fn) __define_initcall("5s",fn,5s)
#define rootfs_initcall(fn) __define_initcall("rootfs",fn,rootfs)
#define device_initcall(fn) __define_initcall("6",fn,6)
#define device_initcall_sync(fn) __define_initcall("6s",fn,6s)
#define late_initcall(fn) __define_initcall("7",fn,7)
#define late_initcall_sync(fn) __define_initcall("7s",fn,7s)
#define __initcall(fn) device_initcall(fn)
#define __exitcall(fn) \
static exitcall_t __exitcall_##fn __exit_call = fn
#define console_initcall(fn) \
static initcall_t __initcall_##fn \
__used __section(.con_initcall.init) = fn
#define security_initcall(fn) \
static initcall_t __initcall_##fn \
__used __section(.security_initcall.init) = fn
#define __setup_param(str, unique_id, fn, early) \
static const char __setup_str_##unique_id[] __initconst \
__aligned(1) = str; \
static struct obs_kernel_param __setup_##unique_id \
__used __section(.init.setup) \
__attribute__((aligned((sizeof(long))))) \
= { __setup_str_##unique_id, fn, early }