블록 디자인은 다음과 같다.

class DesignOfBlocStorage <T> {

    

    var storage: Array <T?>

    

    init() {

        storage = Array<T?>(repeating: nil, count: GS.s.hjhMaxBlocksVertical * GS.s.hjhMaxBlocksHorizontal)

    }

    

    subscript(currentPositon: Int) -> T? {

        get {

            return storage[currentPositon]

        }

        

        set(newValue) {

            storage[currentPositon] = newValue

        }

    }

    

    subscript(currentXposition: Int, currentYposition: Int) -> T? {

        get {

            return storage[(currentYposition * GS.s.hjhMaxBlocksHorizontal) + currentXposition]

        }

        

        set(newValue) {

            storage[(currentYposition * GS.s.hjhMaxBlocksHorizontal) + currentXposition] = newValue

            if GS.s.logLevel == .fixing {

                debugPrint("saving Point to BlocStorage", (currentYposition * GS.s.hjhMaxBlocksHorizontal) + currentXposition, GS.s.hjhBlocStorage?[((currentYposition * GS.s.hjhMaxBlocksHorizontal) + currentXposition)]?.mYposition) }

        }

    }

    

    func clean() {

        self.storage.removeAll()

        self.storage = Array<T?>(repeating: nil, count: GS.s.hjhMaxBlocksVertical * GS.s.hjhMaxBlocksHorizontal)

    }

}

딱히 특별할 것은 없는...

싱글톤 많이 안써야 하는데ㅡㅡ; 

쩝... 혼자 만들면 굳이 클래스를 나눌 필요성도 사실 못 느낀다.

디자인 패턴 강의를 많이 하니까 어쩔 수 없지만 ㅠㅠ

--> 만들어 봐야 진짜 아는 거거든... 강의 한다고 아는게 아니라.

'Blog History' 카테고리의 다른 글

433  (0) 2020.06.07
432  (0) 2020.06.07
430  (0) 2020.06.06
429  (0) 2020.06.06
428  (0) 2020.06.06

+ Recent posts