Giter Club home page Giter Club logo

rset's Introduction

rset

使用


func main() {

	// 新建一个RSet
	rset := collection.NewSet(test_data.StudentsGood, test_data.StudentsBad)

	printSet(rset)
	fmt.Println("---------------")
	rset.SortDescDowngradeBy("Id") 	// 集合按照排序字段顺次降级排序
	printSet(rset)
	fmt.Println("---------------")
	rset.SortAscDowngradeBy("Id") 	// 集合按照排序字段顺次升级排序
	printSet(rset)

	fmt.Println("")
	fmt.Println("----------------------------------------------")


	s := rset.SkipReturn(1).LimitReturn(2) // 留下第1个开始连续2个元素
	printSet(&s)

	fmt.Println("----------------------------------------------")

	std1 := test_data.Student{
		Id:5,
		Name:"小金李",
		Age:0,
		IsNewbie:true,
	}
	rset.Add(std1)	 // 添加一个元素
	printSet(rset)

	fmt.Println("----------------------------------------------")

	var newStudentCanInterface interface{} = []test_data.Student{}	// 新建一个装载结果的interface{}容器
	fmt.Println("fill前的newStudentCanInterface", newStudentCanInterface)

	rset.Fill(&newStudentCanInterface)								// 将rset填充到容器
	fmt.Println("fill之后的newStudentCanInterface", newStudentCanInterface)

	newStudentCan := newStudentCanInterface.([]test_data.Student)	// 将interface{}转换成其原始类型
	fmt.Println("强转对象之后的newStudentCan:", newStudentCan)

}

func printSet(rset *collection.RSet) {
	for _, obj := range rset.Set {
		fmt.Printf("%d,%s,%d,%-v\n", obj["Id"], obj["Name"], obj["Age"], obj["IsNewbie"])
	}
}


rset's People

Contributors

ascode avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.