June 12th Friday (六月 十二日 金曜日)

本文分享了一款使用JavaScript实现的战略游戏的试玩体验,强调了其生动性和未来网页游戏的发展趋势,并简要介绍了一个用C++实现的双向链表模板类。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  I played an demo about a strategic game.  It is so vivid.  That is implemented in Javascript.  Web game will
become a fashion in the future.

  I need a good rest for long, although I am going to learn javascritpt.

//GList.cpp
#include <stdlib.h>
#include <string.h>
#include <iostream>

using namespace std;

template <class T>
class List {
    struct _Node {
        T val;
        struct _Node *prev;
        struct _Node *next;
    };
private:
    int _node_num;
    struct _Node *_head;
    struct _Node *_tail;
   
    struct _Node *_current;

public:
    List() : _node_num(0), _head(NULL), _tail(NULL), _current(NULL) {
    }

    void add(T val) {
        struct _Node *p = NULL;
        p = (struct _Node *)malloc(sizeof(struct _Node));
        if (p) {
            p->next = NULL;
            p->prev = NULL;
            if (!_head) {
                _head = p;
                _tail = p;
            }
            else {
                _tail->next = p;
                p->prev = _tail;
                _tail = p;
            }
            p->val = val;
           
            _node_num++;
        }
    }
   
    inline bool isEmpty() {
        return (!_head) ? true : false;
    }
   
    T begin() {
        _current = _head;
        return _head->val;
    }
   
    bool hasMore() {
        return (_current->next) ? true : false;
    }
   
    T next() {
        _current = _current->next;
        return _current->val;
    }

    ~List() {
        struct _Node *p = NULL;

        for (p = _head; p; p = _head) {
            _head = p->next;
            free(p);
        }
       
        _node_num = 0;
        _head = NULL;
        _tail = NULL;
        _current = NULL;
    }
};

int main() {
    List<int> listInt;

    for (int i = 0; i < 10; i++)
        listInt.add(i);
   
    if (!listInt.isEmpty()){
       cout<<listInt.begin()<<endl;
       while(listInt.hasMore())
           cout<<listInt.next()<<endl;
    }

    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值