입어야 한다
화요일, 4월 17, 2012
목요일, 11월 15, 2007
월요일, 12월 11, 2006
월요일, 10월 23, 2006
기름기 없는 감자칩 만들기
블로그 > 매일 행복하게 살고픈 ... http://blog.naver.com/0807twins/110009875522
예전에 감자를 전자렌지에 돌려 칩을 만들었던게 생각나서 ..........
아주 간단하게....
고구마를 깨끗하게 씻어 껍질을 벗기고 얇게 통으로 썰어 무에 담궈서 전분을 빼준다.
키친타올에 물기를 닦고 나무꼬치에 간격을 두고 꽂아 깊이가 있는그릇에 걸쳐서 렌지에 돌린다.
3~4분정도 돌려주면 바삭한 생고구마칩이된다.
예전에 감자를 전자렌지에 돌려 칩을 만들었던게 생각나서 ..........
아주 간단하게....
고구마를 깨끗하게 씻어 껍질을 벗기고 얇게 통으로 썰어 무에 담궈서 전분을 빼준다.
키친타올에 물기를 닦고 나무꼬치에 간격을 두고 꽂아 깊이가 있는그릇에 걸쳐서 렌지에 돌린다.
3~4분정도 돌려주면 바삭한 생고구마칩이된다.
일요일, 7월 02, 2006
ArrayList객체의 접근비용( The access cost of ArrayList Object )
package iteratorVSarray;
import java.util.ArrayList;
import java.util.Iterator;
import kr.ac.kyungnam.dblab.*;
public class Test {
/**
* @param args
*/
public static void perform(Object o) {
}
public static void main(String[] args) {
/*
* First, invoke all of the Benchmark class' method.
* Because of the character of static method's which is being loaded when class is loading.
*/
Benchmark.start();
Benchmark.finish();
Benchmark.result();
/*
* Make 1000000 Integer ArrayList Object
* The index number of ArrayList al is the same as the value
*
* and check the creation Time.
*/
Benchmark.start();
ArrayList al = new ArrayList();
for(int i = 0; i < 1000000; i++) {
al.add( new Integer(i) );
}
Benchmark.finish();
System.out.println("create Sample 1000000 Arraylist Data :" + Benchmark.result() + "ms");
System.out.println();
/*
* Check Iterator creation time
*/
Benchmark.start();
Iterator it = al.iterator();
Benchmark.finish();
System.out.println("getting iterator : " + Benchmark.result() + "ms" );
Benchmark.start();
for(; it.hasNext(); )
perform(it.next());
Benchmark.finish();
System.out.println("iteration time: " + Benchmark.result()+ "ms");
System.out.println();
Benchmark.start();
for(int i = 0 ; i < al.size() ; i++) {
perform(al.get(i));
}
Benchmark.finish();
System.out.println("Arraylist's get(n) method:" + Benchmark.result() + "ms");
System.out.println();
Benchmark.start();
Integer[] iv = new Integer[al.size()];
iv = (Integer[])al.toArray(iv);
Benchmark.finish();
System.out.println("convert ArrayList type to Integer[] :" + Benchmark.result() + "ms");
Benchmark.start();
Object[] ov = al.toArray();
Benchmark.finish();
System.out.println("convert ArrayList type to Object[] :" + Benchmark.result() + "ms");
Benchmark.start();
for(int i = 0 ; i < iv.length ; i++) {
perform(iv[i]);
}
Benchmark.finish();
System.out.println("getting Integer[]'s all element:" + Benchmark.result() + "ms" );
}
}
결과
Iterator Pattern (Internal iterator 구현 class)
package internalVersion;
/*
* Aggregate인터페이스는
* 집합적연 요소를 가지는 클래스에
* iterator메소드를 구현하게 함으로서
* iterator를 제공하게 한다.
*/
interface Aggregate {
public Iterator iterator();
}
/*
* Iterator메소드는 집합적 요소 구성물의 현제 엘리먼트를 반환후 다음엘리먼트로 포인터 이동(next)과 그리고 다음엘리먼트를 가지는지의
* 여부(hasNext)를 가지는 메소드를 가진다. hasPrev 또는 moveToFirst 또는 moveToLast메소드를 추가할 수 있다.
*/
interface Iterator {
public Object next();
public boolean hasNext();
}
/*
* My list는 어떤 집합적 요소를 반환하는 샘플 클래스로 이는 내부 배열값을 가지고 이것을 반환할수 있는 함수 그리고 MyList의
* 크기를 반환하는 함수로 구성된다.
*/
class MyList implements Aggregate {
String[] r = { "abc", "cde","efg" };
public String get(int index) {
return r[index];
}
public int getLength() {
return r.length;
}
/*
* Iterator 인터페이스를 실제루 구현한 MyListIterator MyList의 메소드를 이용하여 집합적 요소를 탐색한다.
*/
private class MyListIterator implements Iterator {
int index = 0;
public Object next() {
return MyList.this.get(index++);
}
public boolean hasNext() {
return index != MyList.this.getLength();
}
}
public Iterator iterator() {
return new MyListIterator();
}
}
/*
* 실제 사용을 보여주는 Example
*/
public class Test {
public static void main(String[] args) {
// MyList객체 선언
MyList m = new MyList();
// 이터레이터 생성
Iterator i = m.iterator();
// 다음 요소를 가지지 않으을때 까지 현재요소를 출력한다.
while (i.hasNext())
System.out.println(i.next());
}
}
Type safe ENUM in C++
#include <iostream>
#include "stdafx.h"
using namespace std;
class FileType
{
private:
int code;
char* name;
FileType(int i,const char* nname) {
code = i;
name = (char *)nname;
}
protected:
public:
static const FileType* File;
static const FileType* Dir;
int getCode() const
{
return code;
}
char* toString() const
{
return name;
}
};
const FileType* FileType::File = new FileType(0,"File Type");
const FileType* FileType::Dir = new FileType(0,"Directory Type");
int _tmain(int argc, _TCHAR* argv[])
{
const FileType *ft = FileType::File;
cout << FileType::File->toString() << endl;
cout << FileType::Dir->toString() << endl;
if( ft == FileType::File )
{
cout << "파일타입" << endl;
}
else if( ft == FileType::Dir )
{
cout << "디렉토리 타입" << endl;
}
return 0;
}
Josua Bloch의 자바 버전의 Typesafe Enum을 C++로 구현 시도해보았다.
무언가 엉성한 감이 있고, 실제로 이런식으로 Enum을 쓸바에 그냥 C++의
키워드로 있는 Enum을 쓰는게 더 낫다는 생각도 가진다.
수요일, 5월 17, 2006
자바 Tiger의 System.nanoTime 추가 !!
나노초 단위의 체크가 가능한 System클래스내의 nanoTime메소드가 추가되었다
비로소 더 정확한 알고리즘의 수행속도 Check가 가능하다.
다음은 샘플이지만 결국 간단하게 사용할 수 밖에 없을 것이다.
static의 클래스레벨의 속성 때문에 여러군데에서 동시에 벤치마크를 수행할 수 없다.
하지만 간단한 수행시간 체크정도는 수행할 것이다.
비로소 더 정확한 알고리즘의 수행속도 Check가 가능하다.
다음은 샘플이지만 결국 간단하게 사용할 수 밖에 없을 것이다.
static의 클래스레벨의 속성 때문에 여러군데에서 동시에 벤치마크를 수행할 수 없다.
하지만 간단한 수행시간 체크정도는 수행할 것이다.
package kr.ac.kyungnam.dblab;
public class Benchmark {
/**
* The field that has starting time
*/
private static long startTime = 0;
/**
* The field that has ending time
*/
private static long endTime = 0;
/**
* The method that set the starting time
*/
public static void start() {
//startTime = System.currentTimeMillis();
startTime = System.nanoTime();
}
/**
* The method that set the finishing time
*/
public static void finish() {
//endTime = System.currentTimeMillis();
endTime = System.nanoTime();
}
/**
* the difference between endtime and starttime
* @return
* return nano second time
*/
public static long result() {
return endTime - startTime;
}
}
목요일, 5월 11, 2006
Simple "Iterator Pattern" Example by Mjseo (외부 Iterator구현 클래스)
/*
* Aggregate인터페이스는
* 집합적연 요소를 가지는 클래스에
* iterator메소드를 구현하게 함으로서
* iterator를 제공하게 한다.
*/
interface Aggregate {
public Iterator iterator();
}
/*
* Iterator메소드는
* 집합적 요소 구성물의 현제 엘리먼트를 반환후 다음엘리먼트로 포인터 이동(next)과
* 그리고 다음엘리먼트를 가지는지의 여부(hasNext)를 가지는 메소드를 가진다.
* hasPrev 또는 moveToFirst 또는 moveToLast메소드를 추가할 수 있다.
*/
interface Iterator {
public Object next();
public boolean hasNext();
}
/*
* My list는 어떤 집합적 요소를 반환하는 샘플 클래스로
* 이는 내부 배열값을 가지고 이것을 반환할수 있는 함수
* 그리고 MyList의 크기를 반환하는 함수로 구성된다.
*/
class MyList implements Aggregate {
String[] r = { "abc", "cde" };
public String get(int index) {
return r[index];
}
public int getLength() {
return r.length;
}
public Iterator iterator() {
return new MyListIterator(this);
}
}
/*
* Iterator 인터페이스를 실제루 구현한 MyListIterator
* MyList의 메소드를 이용하여 집합적 요소를 탐색한다.
*/
class MyListIterator implements Iterator {
int index = 0;
MyList ml;
public MyListIterator(MyList ml) {
this.ml = ml;
}
public Object next() {
return ml.get(index++);
}
public boolean hasNext() {
if (index == ml.getLength())
return false;
else
return true;
}
}
/*
* 실제 사용을 보여주는 Example
*/
public class Test {
public static void main(String[] args) {
// MyList객체 선언
MyList m = new MyList();
// 이터레이터 생성
Iterator i = m.iterator();
// 다음 요소를 가지지 않으을때 까지 현재요소를 출력한다.
while (i.hasNext())
System.out.println(i.next());
}
}
피드 구독하기:
덧글 (Atom)




