func (s *IPSet) GetIPs(limit int) (ips []net.IP) {
	if limit == 0 {
		limit = int(^uint(0) >> 1)  
	}
	for node := s.tree.first(); node != nil; node = node.next() {
		ips = append(ips, expandNet(node.net, limit-len(ips))...)
	}
	return
}
GetIPs retrieves a slice of the first IPs in the set ordered by address up
to the given limit.
package netaddr
import (
	"net"
)
type IPSet struct {
	tree *ipTree
}
func (s *IPSet) InsertNet(net *net.IPNet) {
	if net == nil {
		return
	}
	newNet := net
	for {
		newNode := &ipTree{net: newNet}
		s.tree = s.tree.insert(newNode)
		if s.tree != newNode && newNode.up == nil {
			break
		}
		prev := newNode.prev()
		if prev != nil {
			if ok, n := canCombineNets(prev.net, newNet); ok {
				newNet = n
			}
		}
		next := newNode.next()
		if next != nil {
			if ok, n := canCombineNets(newNet, next.net); ok {
				newNet = n
			}
		}
		if newNet == newNode.net {
			break
		}
	}
}
func (s *IPSet) RemoveNet(net *net.IPNet) {
	if net == nil {
		return
	}
	s.tree = s.tree.removeNet(net)
}
func (s *IPSet) ContainsNet(net *net.IPNet) bool {
	if s == nil || net == nil {
		return false
	}
	return s.tree.contains(&ipTree{net: net})
}
func (s *IPSet) Insert(ip net.IP) {
	s.InsertNet(ipToNet(ip))
}
func (s *IPSet) Remove(ip net.IP) {
	s.RemoveNet(ipToNet(ip))
}
func (s *IPSet) Contains(ip net.IP) bool {
	return s.ContainsNet(ipToNet(ip))
}
func (s *IPSet) Union(other *IPSet) (newSet *IPSet) {
	newSet = &IPSet{}
	s.tree.walk(func(node *ipTree) {
		newSet.InsertNet(node.net)
	})
	other.tree.walk(func(node *ipTree) {
		newSet.InsertNet(node.net)
	})
	return
}
func (s *IPSet) Difference(other *IPSet) (newSet *IPSet) {
	newSet = &IPSet{}
	s.tree.walk(func(node *ipTree) {
		newSet.InsertNet(node.net)
	})
	other.tree.walk(func(node *ipTree) {
		newSet.RemoveNet(node.net)
	})
	return
}