package deprecated

import (
	
	
)

// Int96 is an implementation of the deprecated INT96 parquet type.
type Int96 [3]uint32

// Int32ToInt96 converts a int32 value to a Int96.
func ( int32) ( Int96) {
	if  < 0 {
		[2] = 0xFFFFFFFF
		[1] = 0xFFFFFFFF
	}
	[0] = uint32()
	return
}

// Int64ToInt96 converts a int64 value to Int96.
func ( int64) ( Int96) {
	if  < 0 {
		[2] = 0xFFFFFFFF
	}
	[1] = uint32( >> 32)
	[0] = uint32()
	return
}

// IsZero returns true if i is the zero-value.
func ( Int96) () bool { return  == Int96{} }

// Negative returns true if i is a negative value.
func ( Int96) () bool {
	return ([2] >> 31) != 0
}

// Less returns true if i < j.
//
// The method implements a signed comparison between the two operands.
func ( Int96) ( Int96) bool {
	if .Negative() {
		if !.Negative() {
			return true
		}
	} else {
		if .Negative() {
			return false
		}
	}
	for  := 2;  >= 0; -- {
		,  := [], []
		switch {
		case  < :
			return true
		case  > :
			return false
		}
	}
	return false
}

// Int converts i to a big.Int representation.
func ( Int96) () *big.Int {
	 := new(big.Int)
	.Or(, big.NewInt(int64([2])<<32|int64([1])))
	.Lsh(, 32)
	.Or(, big.NewInt(int64([0])))
	return 
}

// Int32 converts i to a int32, potentially truncating the value.
func ( Int96) () int32 {
	return int32([0])
}

// Int64 converts i to a int64, potentially truncating the value.
func ( Int96) () int64 {
	return int64([1])<<32 | int64([0])
}

// String returns a string representation of i.
func ( Int96) () string {
	return .Int().String()
}

// Len returns the minimum length in bits required to store the value of i.
func ( Int96) () int {
	switch {
	case [2] != 0:
		return 64 + bits.Len32([2])
	case [1] != 0:
		return 32 + bits.Len32([1])
	default:
		return bits.Len32([0])
	}
}

func ( []Int96) int {
	 := 0
	for  := range  {
		 := [].Len()
		if  >  {
			 = 
		}
	}
	return 
}

func ( []Int96) ( Int96) {
	if len() > 0 {
		 = [0]
		for ,  := range [1:] {
			if .Less() {
				 = 
			}
		}
	}
	return 
}

func ( []Int96) ( Int96) {
	if len() > 0 {
		 = [0]
		for ,  := range [1:] {
			if .Less() {
				 = 
			}
		}
	}
	return 
}

func ( []Int96) (,  Int96) {
	if len() > 0 {
		 = [0]
		 = [0]
		for ,  := range [1:] {
			if .Less() {
				 = 
			}
			if .Less() {
				 = 
			}
		}
	}
	return , 
}

func ( []Int96) int {
	if len() > 1 {
		if int96AreInAscendingOrder() {
			return +1
		}
		if int96AreInDescendingOrder() {
			return -1
		}
	}
	return 0
}

func int96AreInAscendingOrder( []Int96) bool {
	for  := len() - 1;  > 0; -- {
		if [].Less([-1]) {
			return false
		}
	}
	return true
}

func int96AreInDescendingOrder( []Int96) bool {
	for  := len() - 1;  > 0; -- {
		if [-1].Less([]) {
			return false
		}
	}
	return true
}