Beispiel #1
0
        int ReadAllLogs()
        {
            var logReader = new LogReader();
            var linesSeen = 0;

            foreach (var line in logReader)
            {
                var ip = line.GetIP();
                linesSeen++;
            }
            return(linesSeen);
        }
Beispiel #2
0
        int CountUniqueIPs()
        {
            var logReader = new LogReader();
            var ipsSeen   = new HashSet <string>(); // Hashset guarda la numeracion de  la estructura como registros unicos

            foreach (var logLine in logReader)      // O(N)
            {
                var ip = logLine.GetIP();
                if (!ipsSeen.Contains(ip))
                {
                    ipsSeen.Add(ip);
                }
            }
            return(ipsSeen.Count);
        }
        int CountUniqueIPs()
        {
            var logReader = new LogReader();
            var ipsSeen   = new HashSet <string>();

            foreach (var logLine in logReader)
            {
                var ip = logLine.GetIP();
                if (!ipsSeen.Contains(ip))
                {
                    ipsSeen.Add(ip);
                }
            }
            return(ipsSeen.Count);
        }
Beispiel #4
0
        int CountUniqueIPs()
        {
            var logReader = new LogReader();
            //modificamos la estructura de la variable
            var ipsSeen = new HashSet <string>();

            foreach (var logLine in logReader)
            {
                var ip = logLine.GetIP();
                if (!ipsSeen.Contains(ip))
                {
                    ipsSeen.Add(ip);
                }
            }
            return(ipsSeen.Count);
        }
Beispiel #5
0
        int CountUniqueIPs()
        {
            var logReader = new LogReader();
            // var ipsSeen = new List<string>(); hashset es una lista con registro unicos

            var ipsSeen = new HashSet <string>();

            foreach (var logLine in logReader)
            {
                var ip = logLine.GetIP();
                if (!ipsSeen.Contains(ip))
                {
                    ipsSeen.Add(ip);
                }
            }
            return(ipsSeen.Count);
        }
Beispiel #6
0
        int CountUniqueIPs()
        {
            var logReader = new LogReader();
            //var ipsSeen = new List<string>();

            //HashSet : utiliza una tabla hash, por lo que las búsquedas son extremadamente rápidas.
            var ipsSeen = new HashSet <String>();

            foreach (var logLine in logReader)
            {
                var ip = logLine.GetIP();
                if (!ipsSeen.Contains(ip))
                {
                    ipsSeen.Add(ip);
                }
            }
            return(ipsSeen.Count);
        }
Beispiel #7
0
        int CountUniqueIPs()
        {
            var logReader = new LogReader();
            DataStructureType    dataStructureType = DataStructureType.List;
            ICollection <string> ipsSeen           = null;

            switch (dataStructureType)
            {
            case DataStructureType.List: ipsSeen = new List <string>(); break;

            case DataStructureType.HashSet: ipsSeen = new HashSet <string>(); break;

            default: ipsSeen = new List <string>(); break;
            }
            foreach (var logLine in logReader)
            {
                var ip = logLine.GetIP();
                if (!ipsSeen.Contains(ip))
                {
                    ipsSeen.Add(ip);
                }
            }
            return(ipsSeen.Count);
        }