     
     public func cleanPageIndex() {
         hCurrentIndex = nil
+    }
+    
+    func swapValue<T>(_ a: inout T, _ b: inout T) {
+        let temp = a
+        a = b
+        b = temp
+    }
+    
+    func modifying<T>(_ value: inout T, _ function: (inout T) -> ()) {
+        function(&value)
     }
     
     public func layoutContainerViews() {

        contentView.next = datasource.flipView(flipView: self, pageViewWithIndex: contentIndex.next) ?? UIView.init()
        containerView.next.addSubview(contentView.next)
        
        swap(&contentView.basemap.current, &contentView.basemap.pre)
        
        contentView.basemap.current?.removeFromSuperview()
        contentView.basemap.current = datasource.flipView(flipView: self, baseMapViewAtIndex: contentIndex.current)

    }
    
    func swapCurrentToNext() {
        modifying(&containerView) { containerView in swapValue(&containerView.current, &containerView.next) }
        modifying(&contentIndex) { contentIndex in swapValue(&contentIndex.current, &contentIndex.next) }
        modifying(&contentView) { contentView in swapValue(&contentView.current, &contentView.next) }
        
        modifying(&containerView) { containerView in swapValue(&containerView.next, &containerView.pre) }
        modifying(&contentView) { contentView in swapValue(&contentView.next, &contentView.pre) }
        modifying(&contentIndex) { contentIndex in swapValue(&contentIndex.next, &contentIndex.pre) }
        
        hCurrentIndex = contentIndex.current
    }
    
    func swapCurrentToPre() {
        modifying(&containerView) { containerView in swapValue(&containerView.current, &containerView.pre) }
        modifying(&contentIndex) { contentIndex in swapValue(&contentIndex.current, &contentIndex.pre) }
        modifying(&contentView) { contentView in swapValue(&contentView.current, &contentView.pre) }
        
        modifying(&containerView) { containerView in swapValue(&containerView.pre, &containerView.next) }
        modifying(&contentIndex) { contentIndex in swapValue(&contentIndex.pre, &contentIndex.next) }
        modifying(&contentView) { contentView in swapValue(&contentView.pre, &contentView.next) }
        
        hCurrentIndex = contentIndex.current
    }
