LoginSignup
0
0

More than 3 years have passed since last update.

チート付きスタック

Last updated at Posted at 2020-12-06

初めに

色々あってコードを一本書いたのでそれを上げに来ました。
あまり人の構造をいじりたいとは思いませんが、今負荷がかかっていてそれどころでは無いので、仕方なく考えた構造を上げておきます。参考にはしない方がいいです。

それは何か

それは、チート機能付きスタックです。機能カット版のほとんどSTLのベクターなのです。

コード

code.cpp
#include <iostream>
#include <vector>

//これは、記憶の持ち方についての言及です。
//シーク付きスタックに思路をプッシュして、それを回想できるように願ったものです。
//私の願いが叶いますように。

//hmm, how i make vecstack like this...


template<class T>
class VectorStack {
public:

    const T& Peek() const {
        return V.back();
    }

    bool Pop() {
        V.pop_back();
        return true;
    }
    bool Push(const T& In) {
        V.push_back(In);
        return true;
    }

    const T& operator [](std::size_t Idx) const{
        return V[Idx];
    }

    typename std::vector<T>::const_iterator begin() const{
        return V.cbegin();
    }
    typename std::vector<T>::const_iterator end() const{
        return V.cend();
    }

protected:
    std::vector<T> V;
};

struct Thought {//not define yet. 適当定義・・・。Orz
    int rune = 0;
    int prop19 = 0;
    int param21 = 0;
};

int main() {

    VectorStack<Thought> M;
    Thought T{ 0, };

    M.Push(T);
    T.rune = 2;
    M.Push(T);

    for (auto& o : M) {
        std::cout << o.rune << std::endl;
    }
    return 0;

}

終わりに

最近、禊が終わりまして色々後処理をしているのですが、ほんとソフトウエア的な投資をしておいてよかったと思います。
とにかく、思考やら認識やらが狂うとほんとうにどうしようもないので、そこだけでもケアしてあれ
数十倍マシになります。

かしこ。

追記

より良い記憶構造を願うなら、スタック付きグラフか、スタック付きツリーを模索するべきかもしれません。
スタックには思路や支点を持たせるとよいでしょう。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0